Skip to content
Prev 175109 / 398506 Next

Sort by timestamp

Good morning Johannes,

This might help. Try:

df <- data.frame(V1=as.factor(c('2008-10-14 09:10:00','2008-10-14
9:20:20','2008-10-14 08:45:00')),V2=runif(3))

df           # is a dataframe, just as yours

class(df$V1) # is a factor, just as yours. See ?factor
             # This will probably not be ordered
             # in a way you like.

df$V1 <- as.POSIXct(df$V1, tz='CET') # makes it a time. See ?POSIXct

class(df$V1) # is a POSIX time now

df2 <- df[do.call(order, df), ] # see ?order

df2          # sorted in a way you like


Cheers, Arien
On Thu, March 26, 2009 08:54, j.k wrote: