[R] How do you sort a data frame on a selection of columns?
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Jul 8 02:22:58 CEST 2005
On 7/7/05, Briggs, Meredith M <Meredith.Briggs at team.telstra.com> wrote:
> This is what to start with:
>
> Data Frame A B C D
> c1 4 y 5
> c3 6 d 7
> c1 5 t 6
>
> Now sort on A then C
>
> This is what to end with:
>
> Data Frame A B C D
> c1 5 t 6
> c1 4 y 5
> c3 6 d 7
>
DF[order(DF$A, DF$C),]
There is also a function posted on r-help that can do this
easier. Try
RSiteSearch("sort.data.frame")
More information about the R-help
mailing list