[R] Sort a dataframe on the column Date

Mark Knecht markknecht at gmail.com
Tue Jul 28 15:01:50 CEST 2009


On Mon, Jul 27, 2009 at 11:46 PM, Meenu Sahi<meenusahi at gmail.com> wrote:
> Dear Users
> I have a dataframe called mydata4 of the following order with the first
> column as a date and the rest of the columns are numeric with rate.
> Column 1          Rate1 : Rate 20
> (PxMid)
> 01/01/2003
> 07/01/2001
> ----
> ----
> --
>
> I wish to sort this dataframe on the first col in ascending order.
> I tried to do the following
> mydata4<-mydata4[,order(mydata4$PxMid)]
> This give an error.
>
> Please help.
>
> Regards
> Meenu

Try

mydata4<-mydata4[order(mydata4$PxMid), ]

Cheers,
Mark




More information about the R-help mailing list