如何最好地将时间序列压缩到不同的持续时间?

How to best compress timeseries into a different duration?

我有一个这样定义的时间序列对象:

tser <- ts(cumsum(1 + rnorm(48)), frequency = 12, start = c(2010, 1))

数据看起来类似于下面(被剪裁以仅显示一年)

        Jan        Feb        Mar        Apr        May        Jun        Jul        Aug        Sep        Oct        Nov        Dec
  2010  0.6055677  2.8650543  2.6115597  3.1496051  2.6611612  4.4993758  6.0717509  6.9426434  7.1386547  7.1653957  8.2570628  7.8585075

我想将此数据汇总为季度数据。所以每个季度我只会看到一个值。

除了每个月走一遍并汇总自己之外,是否有推荐的方法来做到这一点?

aggregate.tssummean 或任何所需的摘要函数一起使用。参见 ?aggregate.ts

> aggregate(tser, 4, sum)
          Qtr1      Qtr2      Qtr3      Qtr4
2010  10.21558  15.22923  21.98924  30.94460
2011  39.81982  45.00208  61.26129  73.03194
2012  87.63780  97.27455 104.69757 115.09325
2013 126.71070 138.39925 145.47344 159.00137