rollsum | R Documentation |
Compared with zoo::rollsum()
, this function is implemented in C and is one
magnitude faster.
rollsum( x, k, na_pad = FALSE, na.rm = FALSE, align = c("center", "left", "right") )
x |
A numeric vector. |
k |
integer width of the rolling window. |
na_pad |
Logical value about whether to pad left/right ends with NAs. |
na.rm |
Similar to |
align |
Character specifying whether the index of the result should be left- or right-aligned or centered (default) compared to the rolling window of observations. |
The rolling sum.
zoo::rollsum()
x <- 1:10 # Basic usage rollsum(x, k = 3) # Align at the right end, and use NA for padding rollsum(x, k = 3, na_pad = TRUE, align = "right")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.