[R] How to sort a dataframe by one variable

2005-06-28 Thread Lisa Wang
Hi there, Could anybody help me on how to sort a dataframe by one variable in the dataframe? Thank you Lisa Wang Princess Margaret Hospital Toronto, Ca tel: 416 946 4501 __ R-help@stat.math.ethz.ch mailing list

Re: [R] How to sort a dataframe by one variable

2005-06-28 Thread Sundar Dorai-Raj
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 __ R-help@stat.math.ethz.ch mailing

Re: [R] How to sort a dataframe by one variable

2005-06-28 Thread Francisco J. Zagmutt
Try RSiteSearch(Sort data frame). Anyhow, use order() or sort.list() as follows: dat[order(dat[,'myColumn']),]#Sorts data.frame dat by column myColumn dat-dat[sort.list(dat$myColumn, decreasing = T),] #Another option to do the same. You can specify decreasing or increasing within both function