View source: R/transformations.R
ma | R Documentation |
Moving Average
ma(v, width, align = "center", zero = TRUE)
v |
Numeric vector |
width |
Width of moving average window as an integer, v |
align |
Either string "center", "left", or "right" |
zero |
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
.
The modified vector v
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.