[R] sorting dataframe

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Wed Nov 21 11:40:23 CET 2007


- or the orderBy function in the doBy package.
Soren

________________________________

From: r-help-bounces at r-project.org on behalf of Henrik Bengtsson
Sent: Wed 21-11-2007 11:14
To: Rina Oldager Miehs
Cc: r-help at r-project.org
Subject: Re: [R] sorting dataframe



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.
>

______________________________________________
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