[R] Sorting a data frame by one of the variables

ronggui 042045003 at fudan.edu.cn
Sun Oct 16 08:38:59 CEST 2005


FAQ 7.23 How can I sort the rows of a data frame?

To sort the rows within a data frame, with respect to the values in one or more of the columns, simply use order(). 

	

======= 2005-10-16 13:29:44 ÄúÔÚÀ´ÐÅÖÐÐ´µÀ£º=======

>
>Dear all,
>
>I have a date frame like this:
>
>X   Y   Z
>22	24	4.3
>2.3	3.4	5.3
>.....
>....
>57.2	23.4	34
>
>What my purpose is: to sort the data frame by either X, Y or Z.
>sample output is (sorted by X) :
>
>X   Y   Z
>2.3  3.4  5.3
>.....
>......
>22 24  4.3
>...
>57.2  23.4  34
>
>I have no idea how to use sort, order or rank functions. Please help me out.
>Thanks!
>
>Leaf
>
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

= = = = = = = = = = = = = = = = = = = =
			


 

2005-10-16

------
Deparment of Sociology
Fudan University

My new mail addres is ronggui.huang at gmail.com
Blog:http://sociology.yculblog.com




More information about the R-help mailing list