[R] how to sort data frame order by column?

Linlin Yan yanlinlin82 at gmail.com
Sun May 31 08:59:45 CEST 2009


e.g.
dat[ order(dat$a), ]

On Sun, May 31, 2009 at 2:34 PM, Угодай n/a <ugoday at gmail.com> wrote:
> I have a data frame, for exampe
>
>> dat <- data.frame(a=rnorm(5),b=rnorm(5),c=rnorm(5))
>           a            b          c
> 1 -0.1731141  0.002453991  0.1180976
> 2  1.2142024 -0.413897606  0.7617472
> 3 -0.9428484 -0.609312786  0.5132441
> 4  0.1343336  0.178208961  0.7509650
> 5 -0.1402286 -0.333476839 -0.4959459
>
> How to make dat2 from dat, where source data frame be ordered by any column?
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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