Hi listers, I have a data frame with 5 variables... And I want reorder the data frame according a specific variable X... I checked the sort and order functions... In my case I think that the ORDER function is applicable... But I did not understand at all... The idea is simple... Data order by X... I know that this is very simple... Anyways... How I would do that... Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/Order-data-frame-tp24004394p24004394.html Sent from the R help mailing list archive at Nabble.com.
Try this: DF <- data.frame(ID = sample(5), v = rnorm(5)) DF[order(DF$ID),] On Fri, Jun 12, 2009 at 3:54 PM, MarcioRibeiro <mestat@pop.com.br> wrote:> > Hi listers, > I have a data frame with 5 variables... And I want reorder the data frame > according a specific variable X... > I checked the sort and order functions... In my case I think that the ORDER > function is applicable... But I did not understand at all... The idea is > simple... Data order by X... > I know that this is very simple... Anyways... How I would do that... > Thanks in advance, > Marcio > > -- > View this message in context: > http://www.nabble.com/Order-data-frame-tp24004394p24004394.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
I asked Google for "order data.frame" and got some good answers .... Uwe Ligges MarcioRibeiro wrote:> Hi listers, > I have a data frame with 5 variables... And I want reorder the data frame > according a specific variable X... > I checked the sort and order functions... In my case I think that the ORDER > function is applicable... But I did not understand at all... The idea is > simple... Data order by X... > I know that this is very simple... Anyways... How I would do that... > Thanks in advance, > Marcio >
Dear Marcio, Take a look at http://wiki.r-project.org/rwiki/doku.php?id=tips:data-frames:sort <http://wiki.r-project.org/rwiki/doku.php?id=tips:data-frames:sort> HTH, Jorge On Fri, Jun 12, 2009 at 2:54 PM, MarcioRibeiro <mestat@pop.com.br> wrote:> > Hi listers, > I have a data frame with 5 variables... And I want reorder the data frame > according a specific variable X... > I checked the sort and order functions... In my case I think that the ORDER > function is applicable... But I did not understand at all... The idea is > simple... Data order by X... > I know that this is very simple... Anyways... How I would do that... > Thanks in advance, > Marcio > > -- > View this message in context: > http://www.nabble.com/Order-data-frame-tp24004394p24004394.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]