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> xid 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
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 > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
- 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 > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >______________________________________________ R-help at r-project.org mailing list stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Please show the data set........................... -- View this message in context: r.789695.n4.nabble.com/sorting-dataframe-tp840507p4644857.html Sent from the R help mailing list archive at Nabble.com.