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

Jue Lin-Ye jl.iccp at gmail.com
Tue Jan 13 12:37:52 CET 2015


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!​

-- 
Jue Lin-Ye

	[[alternative HTML version deleted]]



More information about the R-help mailing list