Given the following issue with rounding milliseconds under R. How do I get around it so that the times are correct?
> options(digits.secs=3)
> as.POSIXlt("13:29:56.061", format='%H:%M:%OS', tz='UTC')
[1] "2012-06-07 13:29:56.060 UTC"
> as.POSIXlt("13:29:56.062", format='%H:%M:%OS', tz='UTC')
[1] "2012-06-07 13:29:56.061 UTC"
> as.POSIXlt("13:29:56.063", format='%H:%M:%OS', tz='UTC')
[1] "2012-06-07 13:29:56.063 UTC"
I noticed that this URL provides background information but doesn't solve my issue: Milliseconds puzzle when calling strptime in R.
Also this URL touches on the issue but doesn't solve it: R xts: .001 millisecond in index.
In these cases I do see the following:
> x <- as.POSIXlt("13:29:56.061", format='%H:%M:%OS', tz='UTC')
> print(as.numeric(x), digits=20)
[1] 1339075796.0610001087
The URL also seems to indicate that this is just a display issue but I've noticed that using statements like "%OS3" without the options line don't seem to pickup the correct number of digits.
The version I'm using is 32 bit 2.15.0 under Windows but this seems to exist under other situations for R.
Note that my original data is these date time strings within a CSV file I must find a way of converting them into the correct millisecond time from a string.