Calculating moving average

前端 未结 16 1774
夕颜
夕颜 2020-11-21 23:55

I\'m trying to use R to calculate the moving average over a series of values in a matrix. The normal R mailing list search hasn\'t been very helpful though. There doesn\'t s

16条回答
  •  离开以前
    2020-11-22 00:42

    You may calculate the moving average of a vector x with a window width of k by:

    apply(embed(x, k), 1, mean)
    

提交回复
热议问题