anglor <angelica.ekenstam <at> dpes.gu.se> writes: > > Hi, > > I've got a dataframe looking like this: > > DateHour TcuvInt.A TcuvInt.B TcuvInt.C > 1757 2007-03-15 14:00:00 7.83 <NA> > 1758 2007-03-15 14:30:00 7.42 7.69 <NA> > 1759 2007-03-15 15:00:00 7.53 7.75 <NA> > 1760 2007-03-15 15:30:00 7.65 7.73 <NA> > what format are your dates? use str. If they're already one of the many date objects, you can use ?order. Even if they're not, it seems to me they should sort correctly as strings with order also.
df<-df[order(df$DateHour),] -- snip -- as far as formatting your dates, depending on which format you want: ?as.POSIXct and ?as.POSIXlt also check ?strptime df$DateHour<-as.POSIXlt(df$DateHour,format='%F %X') > > Any suggestions? > > And also, I'm quite new at R and this forum, someone suggested I use > > df <- data.frame(x = 1:4, y = rnorm(4), z = rpois(4, 3)) > structure(list(x = 1:4, y = c(-0.24950486967999, 0.151728291232845, > 1.24654200540763, 2.30868457813145), z = c(3, 5, 2, 5)), .Names = c("x", > "y", "z"), row.names = c(NA, -4L), class = "data.frame") > dput(df) > > for a better display of my problem but I don't understand what this does? > > Thank you for help! > > Angelica > > -- > View this message in context: http://r.789695.n4.nabble.com/order-a-data-frame-after-date-and-hour-tp3700721p3700721.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ R-help@r-project.org 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.