Why is there no apply.hourly in R with xts/zoo?

后端 未结 3 1143
孤城傲影
孤城傲影 2020-12-29 14:37

I want to aggregate data by hourly mean. Daily is very easy:

apply.daily(X2,mean)

Why is there no function for hourly? I tried

         


        
3条回答
  •  旧时难觅i
    2020-12-29 15:16

    try

    period.apply(X2, endpoints(X2, "hours"), mean)
    

    apply.daily is simply a wrapper for the above:

    > apply.daily
    function (x, FUN, ...)
    {
        ep <- endpoints(x, "days")
        period.apply(x, ep, FUN, ...)
    }
    

提交回复
热议问题