[R] How to sort a dataframe by one variable

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Wed Jun 29 00:06:32 CEST 2005



Lisa Wang wrote:
> Hi there,
> 
> Could anybody help me on how to sort a dataframe by one variable in the 
> dataframe?
> 
> Thank you
> 

See ?order.

x <- data.frame(a = runif(10), b = 1:10)
x[order(x$a), ]


--sundar




More information about the R-help mailing list