Given
z <- zoo(c(1:10))
I want to be be able to aggregate to the following:
> z
4 8 10
10 26 19
I have tried the following using rollapply but to no avail:
> rollapply(zoo(c(1:10)), width = 4, FUN = "sum", by = 4, partial = TRUE, align = "right")
1 5 9
1 14 30
> rollapply(zoo(c(1:10)), width = 4, FUN = "sum", by = 4, partial = TRUE, align = "left")
1 5 9
10 26 19
> rollapply(zoo(c(1:10)), width = 4, FUN = "sum", by = 4, partial = TRUE, align = "center")
1 5 9
6 22 27
Any help would be greatly appreciated. The second looks most promising but I would have to customize a lag?