Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 RI 中,经常按月聚合每日数据(在 a 中zoo),使用如下所示:
zoo
result <- aggregate(x, as.yearmon, "mean", na.rm=TRUE)
有没有办法可以按周做到这一点?
最简单的方法是使用apply.weekly函数 from xts。
apply.weekly
xts
> apply.weekly(zoo(1:10, as.Date("2010-01-01") + 1:10), mean) 2010-01-03 2010-01-10 2010-01-11 3 42 10