In this question the issue of using dates in data.table
s was discussed. A solution is to use the built-in classes for time and dates. These work with a precision up to the second. Is there a work-around to handle milliseconds in indexed columns?
The built-in class for Dates and Times, eg POSIXct
works to milliseconds (windows) and microseconds (Linux, OS X). You probably haven't turned on the option to have subseconds printed:
R> Sys.time() ## under default options
[1] "2011-10-25 17:40:05 CDT"
R> options("digits.secs"=7) ## you may want this in ~/.Rprofile too
R> Sys.time()
[1] "2011-10-25 17:40:11.177271 CDT"
R>
Yeah, data.table requires keys to be integers or similar (i.e. POSIXct rounded to seconds). I would work-around this by storing 1000 * timestamp as your key, and perhaps having a separate column which is the non-rounded POSIXct. Or you can convert to POSIXct on the fly whenever you need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With