[R] Help: sorting data frames

Torsten Hothorn hothorn at rzmail.uni-erlangen.de
Thu Jun 20 15:37:02 CEST 2002


> Hello everyone:
> I have a data frame with two columns of data. I want to create a new 
> data frame, in which the first column is sorted in accending order, and 
> the elements of the second column are properly re-ordered (to be in the 
> same row with their corresponding first column elements)

R> mydf[order(mydf[,1]),]

Torsten

> 
> Could you tell me how to do it? I'd like to avoid "for" loops, etc., 
> since my data frame is very huge.
> 
> Thank you very much,
> Vlad.
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list