In excel a handy tool is the sort data by column ...i.e. i can highlight the whole dataset and sort it according to a particular column...like sort the data in a column in acending or decending order where all the other columns change aswell. I need to do this in R now but dont know how. ...heres an example... Say I have dataset... Header 1 Header 2 Header 3 1 3 Working 12 2 4 Off 1 3 5 Works 2 4 2 Works 13 5 4 Off 5 ...and i want to sort the data by putting the values in the third column in acending order, like this... Header 1 Header 2 Header 3 1 4 Off 1 2 5 Works 2 3 4 Off 5 4 3 Working 12 5 2 Works 13 ...although im sorting column three in acending order all the rows shuffle so that the parameters in each row stay aligned. How do i do this in R? -- View this message in context: http://old.nabble.com/in-excel-i-can-sort-my-dataset%2C-what-do-i-use-in-R-tp26377540p26377540.html Sent from the R help mailing list archive at Nabble.com.
baptiste auguie
2009-Nov-16 19:13 UTC
[R] in excel i can sort my dataset, what do i use in R
?order ?sort 2009/11/16 frenchcr <frenchcr at btinternet.com>:> > > > In excel a handy tool is the sort data by column ...i.e. i can highlight the > whole dataset and sort it according to a particular column...like sort the > data in a column in acending or decending order where all the other columns > change aswell. > > I need to do this in R now but dont know how. > > ...heres an example... > > Say I have dataset... > > ? ? ?Header 1 ? ?Header 2 ? ?Header 3 > 1 ? ? ? ? 3 ? ? ? ? ?Working ? ? 12 > 2 ? ? ? ? 4 ? ? ? ? ?Off ? ? ? ? ? ?1 > 3 ? ? ? ? 5 ? ? ? ? ?Works ? ? ? ?2 > 4 ? ? ? ? 2 ? ? ? ? ?Works ? ? ? ?13 > 5 ? ? ? ? 4 ? ? ? ? ?Off ? ? ? ? ? ?5 > > > ...and i want to sort the data by putting the values in the third column in > acending order, like this... > > ? ? Header 1 ? ?Header 2 ? ?Header 3 > > 1 ? ? ? ? 4 ? ? ? ? ?Off ? ? ? ? ? ?1 > 2 ? ? ? ? 5 ? ? ? ? ?Works ? ? ? ?2 > 3 ? ? ? ? 4 ? ? ? ? ?Off ? ? ? ? ? ?5 > 4 ? ? ? ? 3 ? ? ? ? ?Working ? ? 12 > 5 ? ? ? ? 2 ? ? ? ? ?Works ? ? ? ?13 > > ...although im sorting column three in acending order all the rows shuffle > so that the parameters in each row stay aligned. > > > > How do i do this in R? > -- > View this message in context: http://old.nabble.com/in-excel-i-can-sort-my-dataset%2C-what-do-i-use-in-R-tp26377540p26377540.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Paul Hiemstra
2009-Nov-17 12:38 UTC
[R] in excel i can sort my dataset, what do i use in R
Hi, Take a look at sort_df from the reshape package. cheers, Paul frenchcr schreef:> > In excel a handy tool is the sort data by column ...i.e. i can highlight the > whole dataset and sort it according to a particular column...like sort the > data in a column in acending or decending order where all the other columns > change aswell. > > I need to do this in R now but dont know how. > > ...heres an example... > > Say I have dataset... > > Header 1 Header 2 Header 3 > 1 3 Working 12 > 2 4 Off 1 > 3 5 Works 2 > 4 2 Works 13 > 5 4 Off 5 > > > ...and i want to sort the data by putting the values in the third column in > acending order, like this... > > Header 1 Header 2 Header 3 > > 1 4 Off 1 > 2 5 Works 2 > 3 4 Off 5 > 4 3 Working 12 > 5 2 Works 13 > > ...although im sorting column three in acending order all the rows shuffle > so that the parameters in each row stay aligned. > > > > How do i do this in R? >