moving_average.Rd
The functions adds moving average for an arbitrary number of intervals. The data can be returned sorted or according to the original order.
moving_average(x, x_order, interval, na.rm = FALSE)
x | A vector used to calculate moving average. |
---|---|
x_order | A vector used for sorting of |
interval | A number of intervals for moving average, defaults to
|
na.rm | As in |
A vector of length equivalent to x
with NA
for
n < interval as in x[n]
.
The function can be used independently or within dplyr pipeline.
#> [1] NA NA 53.33333 54.00000 65.33333 73.33333 60.66667 61.66667 #> [9] 59.00000 57.00000