R - rollmean() and other rolling functions from zoo package

03 Oct 2018

Useful functions for computing rolling means, maximums, medians, and sums of ordered observations.

Compute means/medians/… for values in a given window (moving averages/medians/…)

library(zoo)

rollmean(y,3)
#[1] 1.000000 1.333333 1.666667 2.000000
[ R  package  function  ]