[R] time question

Ralf B ralf.bierig at gmail.com
Tue Nov 9 15:18:05 CET 2010


I have this script which I use to get an epoch with accuracy of 1
second (based on R's inability to calculate millisecond-accurate
timestamps -- at least I have not seen a straightforward solution :)
):

nowInSeconds <- as.numeric(Sys.time())
nowInMS <- nowInSeconds * 1000
print(nowInSeconds)
print(as.character(nowInMS))

when running this I get the following:

> nowInSeconds <- as.numeric(Sys.time())
> nowInMS <- nowInSeconds * 1000
> print(nowInSeconds)
[1] 1289312002
> print(as.character(nowInMS))
[1] "1289312002093"


I wonder where the 93 milliseconds come from. Is this a random number?
A rounding error? Can somebody explain this?

Best,
Ralf



More information about the R-help mailing list