[R] Diff time returns 2 hours when there is 1

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jan 13 13:32:50 CET 2015


On 13/01/2015 3:37 AM, Jue Lin-Ye wrote:
> Greetings! I am analysing my data and checking for gaps over 1 hour and
> come across the problem that R tells me that there are many 2 hour gaps.
> When I go into details, I don't see any of these lapses. Is it something
> with the diff() function?
> 
> You can see what I am saying, below:
> 
> ​M<-matrix(c(1999,10,31,1,
>             1999,10,31,2,
>             1999,10,31,3,
>             1999,10,31,4),4,4,byrow=T)
> colnames(M)<-c("YY","MM","DD","HH")
> time<-ISOdatetime(M[,"YY"],M[,"MM"],M[,"DD"],M[,"HH"],0,0)
> print(diff(time))
>> Time differences in hours
> [1] 1 2 1
> 
> ​Has anyone ever seen something like this? I mean, diff() is one of the
> basic functions of R, so it is probable that many people has seen something
> similar, before. However, somehow, I can't find an answer string on
> stackexchange or analogous pages.​
> 
> ​Thanks in advance!​
> 

Is that just daylight savings time ending?  3 AM standard time is two
hours later than 2 AM daylight savings time.

Duncan Murdoch



More information about the R-help mailing list