-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of David Fox
Sent: Tuesday, January 28, 2014 5:15 PM
To: r-help@r-project.org
Subject: [R] Difference between two datetimes
I have a data frame with variable datetime which is of class POSIXct.
Consecutive observations are separated by 30 minutes.
However, some of the differences reported by R give unexpected results.
For example consider the following two consecutive entries:
par.dat$datetime[5944]
[1] 2010-04-04 02:30:00 EST
par.dat$datetime[5945]
[1] 2010-04-04 03:00:00 EST
When I examine the difference, R reports 1.5 hours instead of 30 minutes:
par.dat$datetime[5945]-par.dat$datetime[5944]
Time difference of 1.5 hours
On further investigation it appears there's something peculiar to this
particular date. Other years work fine, eg:
as.POSIXct(2011-04-04 03:00:00)- as.POSIXct(2011-04-04 02:30:00)
Time difference of 30 mins
as.POSIXct(2012-04-04 03:00:00)- as.POSIXct(2012-04-04 02:30:00)
Time difference of 30 mins
as.POSIXct(2009-04-04 03:00:00)- as.POSIXct(2009-04-04 02:30:00)
Time difference of 30 mins
But when I use 2010 I get a difference of 1.5 hours:
as.POSIXct(2010-04-04 03:00:00)- as.POSIXct(2010-04-04 02:30:00)
Time difference of 1.5 hours
Any suggestions?
Thanks,
David Fox.
Daylight savings time change in Australia?
Dan
Daniel Nordlund
Bothell, WA USA
__
R-help@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.