[R] time difference bug?
Bill Szkotnicki
bszk at uoguelph.ca
Thu Aug 14 16:34:53 CEST 2008
Hi,
I am computing some time differences.
Using the linux version of R 2.7.1
And I am getting a strange result ( see below )
I need the difference in minutes.
Actually looking for where it is NOT 15 minutes.
Would anyone know why this could be happening?
Or should I do this another way?
Bill
The script "k0.R"
===============
a=read.table("buzwah005.txt")
d=strptime(paste(a[,1]," ",a[,2]),"%m/%d/%Y %H:%M")
tm=-24*60*as.numeric(as.POSIXlt("2007-1-1")-d) # time since midnight Jan 1
print(tm[2]-tm[1])
x=a[,3]
diffs=round(tm[-1]-tm[-length(tm)])
not15=(1:length(diffs))[diffs!=15]
print(not15)
===============
The R session....
>
> source("k0.R")
[1] 15
[1] 2113 5686 15712
> class(d)
[1] "POSIXt" "POSIXlt"
> d[15711:15714]
[1] "2007-11-04 01:34:00" "2007-11-04 01:49:00" "2007-11-04 02:04:00"
[4] "2007-11-04 02:19:00"
> d[15712]-d[15711]
Time difference of 15 mins
> d[15713]-d[15712]
Time difference of 1.25 hours
> d[15714]-d[15713]
Time difference of 15 mins
>
>
More information about the R-help
mailing list