Skip to content

in excel i can sort my dataset, what do i use in R

3 messages · frenchcr, Baptiste Auguie, Paul Hiemstra

#
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?
#
?order
?sort


2009/11/16 frenchcr <frenchcr at btinternet.com>:
#
Hi,

Take a look at sort_df from the reshape package.

cheers,
Paul

frenchcr schreef: