Re: [R] sort dataframe by field

From: Benilton Carvalho <bcarvalh_at_jhsph.edu>
Date: Wed 17 Jan 2007 - 16:26:30 GMT

say your data.frame is called "df"

df[order(df$evidence),]

or

df[order(df$evidence, decreasing=T),] # if you want the other way around.

b

On Jan 17, 2007, at 11:21 AM, Milton Cezar Ribeiro wrote:

> Hi there,
>
> How can I sort (order?) a data.frame using a dataframe field
> (evidence) as classifyer? My data.frame looks like:
>
> record model evidence
> 1 areatotha 6638.32581
> 2 areatotha_ca000 8111.01860
> 3 areatotha_ca000_Pais 1721.41828
> 4 areatotha_ca020 827.33097
> 5 areatotha_ca020_Pais 2212.40899
> 6 areatotha_ca040 3569.17169
> 7 areatotha_ca040_Pais 2940.01636
> 8 areatotha_ca060 992.62852
> 9 areatotha_ca060_Pais 4237.95709
> 10 areatotha_ca080 62.74915
> 11 areatotha_ca080_Pais 1726.55082
> 12 areatotha_Pais 52.02524
> 13 areatotha_ca000 3391.92930
> 14 areatotha_ca000_Pais 39.52170
> 15 areatotha_ca020 268.55875
> 16 areatotha_ca020_Pais 20.43317
> 17 areatotha_ca040 1698.75892
> 18 areatotha_ca040_Pais 43.90613
> 19 areatotha_ca060 350.79857
> 20 areatotha_ca060_Pais 51.04471
>
> Cheers,
>
> Miltinho, Brazil
>
> __________________________________________________
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.



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 and provide commented, minimal, self-contained, reproducible code. Received on Thu Jan 18 03:33:16 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 17 Jan 2007 - 17:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.