给定
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
任何帮助都将不胜感激。第二个选项似乎最有前途,但我需要自定义一个滞后期?