给定
z <- zoo(c(1:10))
我希望能够汇总到以下内容:
> z
4 8 10
10 26 19
我使用 rollapply 尝试了以下操作,但无济于事:
> 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
任何帮助将不胜感激。第二个看起来最有希望,但我必须定制一个滞后?