[R] sorting dataframe

Henrik Bengtsson hb at stat.berkeley.edu
Wed Nov 21 11:14:05 CET 2007


See order(). -Henrik

On 21/11/2007, Rina Oldager Miehs <rinamiehs at gmail.com> wrote:
> Hello
>
> We have a problem with sorting our dataframe...
> i have tried to write
>
> x <- males[sort(males$index, decreasing=T),]
>
> But that just gives me
>
> > x
>       id sex BVgain BVmeat phenogain phenomeat index
> NA    NA  NA     NA     NA        NA        NA    NA
> NA.1  NA  NA     NA     NA        NA        NA    NA
> NA.2  NA  NA     NA     NA        NA        NA    NA
> NA.3  NA  NA     NA     NA        NA        NA    NA
> NA.4  NA  NA     NA     NA        NA        NA    NA
>
> And that is not right...
>
> We have 7 variables in a dataframe and we need it sorted by one
> variable... how do we do that so we get the same dataframe out just
> sorted....???
> Please help:)
>
> Cincerely Rina Miehs
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list