Aggregate by week in R

后端 未结 1 2005
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 03:41

In R I frequently aggregate daily data (in a zoo) by month, using something like this:

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

相关标签:
1条回答
  • 2020-12-03 03:58

    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 讨论(0)
提交回复
热议问题