开发者

Aggregate by week in R

In R I开发者_如何学JAVA frequently aggregate daily data (in a zoo) by month, using something like this:

result <- aggregate(x, as.yearmon, "mean", na.rm=TRUE)

Is there a way that I can do this by week?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜