Description Usage Arguments Details Value Examples
View source: R/add_moving_average.R
The functions adds moving average for an arbitrary number of intervals. The data can be returned sorted or according to the original order.
1 2 3 4 5 6 7 8 | add_moving_average(
.data,
sort_cols,
val,
intervals = 2,
res_val = "{{val}}_mavg",
restore_order = FALSE
)
|
.data |
A tibble or data frame. |
sort_cols |
Columns used for sorting passed in a manner consistent with
|
val |
Column used to calculate moving average passed as bare column name or a character string. |
intervals |
A number of intervals for moving average. |
res_val |
Resulting moving average, defaults to name of |
restore_order |
A logical, defaults to |
The function can be used independently or within dplyr pipeline.
A tibble with appended moving average.
1 | add_moving_average(mtcars, sort_cols = c("mpg", "cyl"), val = hp, intervals = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.