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

From: Francisco J. Zagmutt <gerifalte28_at_hotmail.com>
Date: Wed 29 Jun 2005 - 08:11:11 EST


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

Cheers

Francisco

>From: Lisa Wang <lisawang@uhnres.utoronto.ca>
>To: R-Help <r-help@stat.math.ethz.ch>
>Subject: [R] How to sort a dataframe by one variable
>Date: Tue, 28 Jun 2005 17:39:40 -0400
>
>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
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html



R-help@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 Received on Wed Jun 29 08:24:17 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:06 EST