[R] Converting ordinal dates and time into sensible formats

Steven Kennedy stevenkennedy2263 at gmail.com
Wed May 11 00:01:35 CEST 2011


How about something like:

> data$DateTime<- strptime(paste(data$day.hour,data$min.sec,sep=" "),format="%j%H %M%S")
> data$Date <- strftime(data$DateTime,format="%Y-%m-%d")
> data$Time <- strftime(data$DateTime,format="%H:%M:%S")
> data
  day.hour min.sec            DateTime       Date     Time
1    12517    2034 2011-05-05 17:20:34 2011-05-05 17:20:34
2    12520    2004 2011-05-05 20:20:04 2011-05-05 20:20:04
3    12507    2045 2011-05-05 07:20:45 2011-05-05 07:20:45
4    12502    2000 2011-05-05 02:20:00 2011-05-05 02:20:00
5    12500    2004 2011-05-05 00:20:04 2011-05-05 00:20:04



More information about the R-help mailing list