moving_mean {dvmisc} | R Documentation |
Calculates moving averages or maximum moving average. For optimal speed, use
integer = TRUE
if x
is an integer vector and
integer = FALSE
otherwise.
moving_mean(x, window, integer = FALSE, max = FALSE)
x |
Integer or numeric vector. |
window |
Integer value specifying window length. |
integer |
Logical value for whether |
max |
Logical value for whether to return maximum moving average (as opposed to vector of moving averages). |
Numeric value or vector depending on max
.
# 5-unit moving average for integer vector of length 10
x <- rpois(10, lambda = 3)
moving_mean(x, 5)