I have used rollmean
in R to calculate a moving average as so:
> x = c(3, 8, 12, 5, 9, 6, 8)
> rollmean(x, 7)
[1] 7.285714
Rollmean
takes an odd number input and calculates the Moving Average, INCLUSIVE of the middle value (in this case 5). However I would like to know if there is a function that allows for calculating the MA around a value, EXCLUDING it, so as to assess the impact around the middle value. Using this example, the average of 3+8+12+9+6+8, not including the middle value 5.
My preference is to avoid having to write a complex function if there is something available.
Thanks!