powered by
Moving Average
ma(v, width, align = "center", zero = TRUE)
The modified vector v
v
Numeric vector
Width of moving average window as an integer, v
Either string "center", "left", or "right"
Boolean to determine the NAs generated by the moving average should be filled with zeros or with the vector's mean.
Applies a moving average on the input vector. The type of moving average is defined by the argument align.
align
ma(c(1,0,0,0,1,0,0,0,2), 3) ma(c(1,0,0,0,1,0,0,0,2), 3, align = "right") ma(c(1,0,0,0,1,0,0,0,2), 3, zero = FALSE)
Run the code above in your browser using DataLab