I recently discovered the data.table package and was now wondering whether or not I should replace some of my plyr-code. To summarize, I really like plyr and I basically achieve
This should work:
DT <- data.table(Date=as.ITime(rep(c(Sys.time(), Sys.time() + 60), each=6)),
y=c(rnorm(6, 1), rnorm(6, -1)))
setkey(DT, Date)
The data.table package contains some date/time classes with integer storage mode.
See ?IDateTime
:
Date and time classes with integer storage for fast sorting and grouping. Still experimental!
IDate
is a date class derived from Date
. It has the same internal representation as the Date
class, except the storage mode is integer. ITime
is a time-of-day class stored as the integer number of seconds in the day. as.ITime
does not allow days longer than 24 hours. Because ITime
is stored in seconds, you can add it to a POSIXct
object, but you should not add it to a Date
object.IDateTime
takes a date-time input and returns a data table with columns date
and time
.