[R] How to sort a dataframe by one variable
Francisco J. Zagmutt
gerifalte28 at hotmail.com
Wed Jun 29 00:11:11 CEST 2005
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 at uhnres.utoronto.ca>
>To: R-Help <r-help at 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 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
More information about the R-help
mailing list