Re: [R] Sorting dataframe by different columns

From: Kevin Wright <kw.statr_at_gmail.com>
Date: Fri, 08 Jun 2007 09:27:43 -0500

On the R wiki site there is a general-purpose function (sort.data.frame) that allows you to do this:

sort(df, by=~ x-z)

See: http://wiki.r-project.org/rwiki/doku.php?id=tips:data-frames:sort

Regards,

Kevin

On 6/8/07, Gunther Höning <gunther.hoening_at_ukmainz.de> wrote:
> Dear list,
>
> I have a very short question,
> Suggest a dataframe of four columns.
>
> df <- data.frame(w,x,y,z)
>
> I want this ordered the following way:
> first by :x, decreasing = FALSE
> and
> secondly by: z, decreasing =TRUE
>
> How can this be done ?

>
> Thanks
>
> Gunther
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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_stat.math.ethz.ch 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. Received on Fri 08 Jun 2007 - 15:27:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Jun 2007 - 16:31:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.