roll: Rolling and Expanding Statistics

Fast and efficient computation of rolling and expanding statistics for time-series data. The default algorithm in the 'roll' package is an online algorithm that, as observations are added to and removed from a window, updates statistics and discards observations from memory (Welford, 1962, <doi:10.1080/00401706.1962.10490022>; West, 1979, <doi:10.1145/359146.359153>); as a result, the amount of time to evaluate each function is significantly shorter because the computation is independent of the window size. In contrast, an offline algorithm requires all observations in memory to calculate the statistic for each window, so users can trade speed for accuracy and select the offline algorithm by setting the online argument to FALSE. Quantiles are computed from the inverse of the empirical distribution function with averaging at discontinuities (Hyndman and Fan, 1996, <doi:10.1080/00031305.1996.10473566>). Use cases include rolling summary statistics, time-varying relationships between variables, and feature engineering for forecasting and signal construction. The package supports rolling and expanding windows, weights, and handling of missing values via the min_obs, complete_obs, and na_restore arguments. The implementation uses 'RcppParallel' to parallelize the online algorithms across columns and the offline algorithms across windows.

Version: 1.2.2
Depends: R (≥ 3.5.0)
Imports: Rcpp, RcppParallel
LinkingTo: Rcpp, RcppArmadillo, RcppParallel
Suggests: covr, testthat, zoo
Published: 2026-11-29
DOI: 10.32614/CRAN.package.roll
Author: Jason Foster [aut, cre]
Maintainer: Jason Foster <jason.j.foster at gmail.com>
BugReports: https://github.com/jasonjfoster/roll/issues
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
URL: https://github.com/jasonjfoster/roll
NeedsCompilation: yes
SystemRequirements: GNU make
Materials: README, NEWS
In views: TimeSeries
CRAN checks: roll results

Documentation:

Reference manual: roll.html , roll.pdf

Downloads:

Package source: roll_1.2.2.tar.gz
Windows binaries: r-devel: roll_1.2.1.zip, r-release: roll_1.2.1.zip, r-oldrel: roll_1.2.1.zip
macOS binaries: r-release (arm64): roll_1.2.2.tgz, r-oldrel (arm64): roll_1.2.2.tgz, r-release (x86_64): roll_1.2.2.tgz, r-oldrel (x86_64): roll_1.2.2.tgz
Old sources: roll archive

Reverse dependencies:

Reverse depends: kcpRS
Reverse imports: dccmidas, dLagM, forceR, respR, rumidas, TrIdent
Reverse linking to: rolleigen, rollshap
Reverse suggests: rolleigen, rolloptim, rollshap

Linking:

Please use the canonical form https://CRAN.R-project.org/package=roll to link to this page.