[R] Incorrect DateTime using ISOdatetime in R

Luke Miller millerlp at gmail.com
Fri Jan 20 18:11:50 CET 2012


666.1751 sure seems like it should return 2010-10-29 04:12:09 based on
your example.

666.1751 days from 2009-01-01 is 2010-10-29 + some hours/min/seconds.

0.1751 days * 24 hrs/day = 4.2024 (i.e. 4:00AM + some minutes).

0.2024 hours * 60 min/hr = 12.144 (i.e. 12 minutes + some seconds).

0.144 minutes * 60 sec/min = 8.64 (i.e. 8.64 seconds).

Put it all together and I get 2010-10-29 04:12:08.64 in the GMT time zone.

What makes you think it should be 2010-10-29 06:12:09? Are you running
into a time zone issue, such as your GPS adjusting its time zone and
reported the time based on the time zone where a reading was taken? If
you crossed between time zones for some of your readings it might
explain the fluctuating difference between the answer you expect and
the answer that ISOdatetime gives you.

-Luke


On Fri, Jan 20, 2012 at 6:59 AM, Sula2011 <julia.somma at gmx.de> wrote:
>
> Dear list,
>
> I need to transform the DateTime of my GPS data from:
>
> "666.1751" into "yyyy/mm/dd hh:mm:ss"
>
> I have the following code:
>
> d$Date <- ISOdatetime(2009, 1, 1, 0, 0, 0, tz = "GMT")+d$Date*(24*3600)
>
> This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10-29
> 06:12:09
>
> Another example:
>
> 418.3219 corresponds to: 2010-02-23 07:43:30, but it should be 2010-02-23
> 08:43:30.
>
> However, not always is the difference + 2 h, it's sometimes less or more.
>
> There are a lot of postings here regarding ISOdatetime, but I'm still not
> able to solve this . Any ideas or suggestions will be very much appreciated.
>
> Best regards,
>
> Julia
>
> PS. I've tried to find the answer in all sorts of R help forums and also in
> my R books - no luck so far. Maybe I'm missunderstanding the entire
> ISOdatetime function?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Incorrect-DateTime-using-ISOdatetime-in-R-tp4313470p4313470.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



More information about the R-help mailing list