Reputation: 1247
I have a zoo time series and I want to add some dummy time steps with same time interval at the end/start. For example, I have the following time series and I want to add two more time steps at the end, for times ......21:00:00 BST
and ......21:30:00 BST
where all observations are zero.
my.zoo.ts = zoo(matrix(c(1:8),ncol=2),
c("2012-07-05 19:00:00 BST", "2012-07-05 19:30:00 BST",
"2012-07-05 20:00:00 BST", "2012-07-05 20:30:00 BST"))
What is the easiest way to do it? (Apart from editing the above code, Of course) )
Upvotes: 0
Views: 93
Reputation: 269654
The series is currently using character strings for times which is not likely what you want so first convert them to POSIXct date/time objects:
time(my.zoo.ts) <- as.POSIXct(time(my.zoo.ts))
The times seem to be spaced by 30 minutes so suppose we want to append 100 and 101 in the two columns at 30 minutes past the last time:
z <- zoo(cbind(100, 101), end(my.zoo.ts) + 30 * 60)
rbind(my.zoo.ts, z)
Upvotes: 1