[R] Possible bug in class 'POSIXlt' when including microseconds?
jim holtman
jholtman at gmail.com
Mon Jul 30 19:26:16 CEST 2012
FAQ 7.31
In floating point, you get about 15 digits of precision. If you look
at the value of time for today you will see:
1343668783
If you add 5 more digits after the decimal point, you will see that
there is not resolution to a microsecond level. I usually assume that
I can get millisecond resolution from POSIXct values.
On Mon, Jul 30, 2012 at 12:52 PM, Janko Thyson
<janko.thyson.rstuff at googlemail.com> wrote:
> Dear list,
>
> I'm a bit puzzled by an ambiguity with respect to the representation of
> micro-/milliseconds when using 'POSIXlt' objects.
>
> It seems that the last digit of the 'sec' attribute sometimes seems to
> differ from the digits shown when printing the 'POSIXlt' object. You'll
> find a little SO post with some example code here:
> http://stackoverflow.com/questions/11725517/ambiguity-with-posixlt-representation-when-microseconds-are-included.
>
> In case you don't want to have a look at that, here's another short example:
>
> |opts<- options(digits.secs=6)
> x<- "2012-07-30 12:10:09.123123"
>
> posix<- as.POSIXlt(x, tz="Europe/Berlin")
>
>> posix
> [1] "2012-07-30 12:10:09.123122 Europe/Berlin"
>
>> posix$sec
> [1] 9.123123
> |
>
> # Manually changing the 'sec' attribute
>
> |posix$sec<- 9.123122
>> posix
> [1] "2012-07-30 12:10:09.123122 Europe/Berlin"
> # Still '.123122'
>
> posix$sec<- 9.123124
>> posix
> [1] "2012-07-30 12:10:09.123124 Europe/Berlin"
> # Now it's '.123124' in both 'representations'
> |
>
>
> Thanks a lot for any clarification on this!
> Janko
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list