[R] shift/lag when merge zoo
j.k
kathan at gmx.at
Wed Apr 15 14:53:19 CEST 2009
Hello alltogheter,
I have a little problem regarding merging to zoo series.
I want to merge two zoo series to reduce the timegaps between the stamps.
I use the following code:
data.test <-
as.POSIXct(seq(data.input01[1,1],data.input01[nrow(data.input01),1],900),tz="GMT")
data.troughput01 <- as.zoo(data.input01$V2)
index(data.troughput01) <- as.POSIXct(data.input01$V1,tz="GMT")
data.output01 <-merge(data.troughput01,zoo(,data.test))
They look like that:
head(data.test)
[1] "2008-01-01 00:00:00 GMT" "2008-01-01 00:15:00 GMT" "2008-01-01 00:30:00
GMT"
[4] "2008-01-01 00:45:00 GMT" "2008-01-01 01:00:00 GMT" "2008-01-01 01:15:00
GMT"
> head(data.troughput01)
2008-01-01 00:00:00 2008-01-01 00:30:00 2008-01-01 01:00:00 2008-01-01
01:30:00
12.24180 11.27340 10.30500
9.33654
2008-01-01 02:00:00 2008-01-01 02:30:00
8.36811 7.62456
> head(data.output01)
2008-01-01 01:00:00 2008-01-01 01:15:00 2008-01-01 01:30:00 2008-01-01
01:45:00
12.2418 NA 11.2734
NA
2008-01-01 02:00:00 2008-01-01 02:15:00
10.3050 NA
Are there any ideas why I have a lag of one hour?
At last I fill the NAs with na.approx:
data.output01 <-merge(data.troughput01,zoo(,data.test))
> head(data.output01)
2008-01-01 01:00:00 2008-01-01 01:15:00 2008-01-01 01:30:00 2008-01-01
01:45:00
12.24180 11.75760 11.27340
10.78920
2008-01-01 02:00:00 2008-01-01 02:15:00
10.30500 9.82077
>
Maybe there are suggestions for other solutions of achieving the increase of
the resolution.
Thanks in advance
Johannes
--
View this message in context: http://www.nabble.com/shift-lag-when-merge-zoo-tp23057867p23057867.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list