在R中按周汇总 [英] Aggregate by week in R
本文介绍了在R中按周汇总的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在RI中,经常使用以下方式每月汇总每日数据(在 zoo
中):
In R I frequently aggregate daily data (in a zoo
) by month, using something like this:
结果<-合计(x,as.yearmon, mean,na.rm = TRUE)
推荐答案
最简单的方法是使用每周
。 xts
中的apply.weekly
The easiest thing to do is to use the apply.weekly
function from 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
这篇关于在R中按周汇总的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文