[R] order intervals in a data.frame
Paul Smith
phhs80 at gmail.com
Thu Sep 6 12:41:08 CEST 2007
On 9/6/07, João Fadista <Joao.Fadista at agrsci.dk> wrote:
> I would like to know how can I order a data.frame with increasing the dat$Interval (dat$Interval is a factor). There is an example below.
>
> Original data.frame:
>
> > dat
> Interval Number_reads
> 0-100 685
> 200-300 744
> 100-200 1082
> 300-400 4213
>
>
> >Desired_dat:
>
> Interval Number_reads
> 0-100 685
> 100-200 1082
> 200-300 744
> 300-400 4213
What about
Desired_dat <- dat[match(dat$Interval,sort(dat$Interval)),]
?
Paul
More information about the R-help
mailing list