| roll_apply | R Documentation |
Computes rolling statistics (mean, sd, median, sum, min, max, var) over a moving window of fixed length. Supports group-wise computation and various alignments.
roll_apply(data, cols = NULL, window = 3, method = "mean",
align = "right", group = NULL, date_col = NULL,
verbose = FALSE)
data |
A data frame, matrix, or numeric vector. |
cols |
Column indices or names to process. |
window |
Window size (number of observations). |
method |
Statistic to compute: |
align |
Alignment of window: |
group |
Optional grouping column for group-wise rolling computation. |
date_col |
Not used. Present for interface consistency. |
verbose |
Logical; if |
A data frame or vector with rolling statistics.
roll_apply(data[1:100, c(1, 4, 17:19)], cols = 3:5, window = 5, method = "mean")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.