Skip to content

RcppRoll

0.4.0Package record

Efficient Rolling / Windowed Operations

24packages dependsuggested by 3
351.2Kdownloads / year
80.5%test coverage
13/13flavors OK

Overview

About

Provides fast and efficient routines for common rolling / windowed operations. Routines for the efficient computation of windowed mean, median, sum, product, minimum, maximum, standard deviation and variance are provided.

Changes in 0.4.0

New features

  • The rolling window computations are now parallelized with OpenMP, where support for it is available. By default, the number of threads is chosen by the OpenMP runtime (e.g. via OMP_NUM_THREADS); it can be set explicitly with options(RcppRoll.threads = <n>), and options(RcppRoll.threads = 1) disables parallelization. Work is split into chunks whose boundaries do not depend on the thread count, so results are identical whatever the number of threads -- including on builds without OpenMP support at all.
  • The new roll_threads() function reports the number of threads in use, or NA when the package was compiled without OpenMP support. The package reports this on attach as well; suppress the startup message with options(RcppRoll.quiet = TRUE). Instructions for enabling OpenMP when installing from sources on macOS are in the README.
Show all changes in 0.4.0Hide the rest of the changes in 0.4.0
  • The partial argument is now implemented. With partial = TRUE, windows at the edges of x are computed over however many elements are in range rather than filled, so the result has one element per element of x. This matches zoo::rollapply(partial = TRUE). (#18) partial = TRUE cannot be combined with weights, and only TRUE or FALSE are accepted -- zoo's numeric "minimum observations" form is not supported. fill does not apply, and is warned about if supplied.

Performance improvements

  • Taken together, the changes below speed up every rolling operation. Benchmarked against RcppRoll 0.3.2 over a vector of one million observations, single-threaded speedups range from about 1.7x for tiny windows to more than 150x for large ones, and an OpenMP build multiplies that by roughly the core count: roll_median() with a 500-element window drops from 13 seconds to 77 milliseconds single-threaded, and to 9 milliseconds on a 14-thread laptop.
  • Rolling windows are now computed incrementally where the operation admits it: a window carries its state forward and pays only for the observations that enter and leave, so the per-point cost no longer grows with the window size. Compensated summation and a rebuild-whenever-degraded check keep the sliding totals accurate -- on badly conditioned inputs the worst relative error falls from about 2e-2 to 3e-14 -- and running totals that overflow to infinity recover once the offending values leave the window. (#51)
  • roll_median() now keeps large windows in a pair of heaps meeting at the median, so that sliding costs O(log n) per point rather than O(n). Windows below about two hundred observations keep the sorted-window representation, which remains faster there.
  • roll_prod() now slides its window incrementally rather than recomputing each window in full, so its cost no longer grows with the window size. The window is carried as two stacks of partial products -- departing values are never divided out, so zeros, infinities and rounding behave as a fresh multiplication would.
  • Matrices whose columns are too short to split into chunks are now parallelized across their columns instead, so wide matrices benefit from OpenMP too. As before, results are identical whatever the number of threads.
  • The window loops that dominate small-window calls have been rewritten branchlessly where measurement showed a win, with bit-identical results: roll_sum() and roll_mean() with na.rm = TRUE run 1.4-2.5x faster, roll_max() with na.rm = TRUE 1.4-1.8x faster, and the weighted roll_median() about 1.8x faster.

Bug fixes

  • roll_var() and roll_sd() now compute a weighted variance when weights is supplied, rather than the variance of the weighted values. Weights are treated as frequency weights, so an equal weight vector gives the same answer as the unweighted routines. (#47)
  • roll_var() and roll_sd() now keep each weight paired with its own value when na.rm = TRUE, instead of shifting the weights when NAs are dropped. (#47)
  • roll_var() and roll_sd() now return NA for a window holding fewer than two non-missing values, matching var(). Previously an all-NA window gave 0 and a single-value window gave NaN. (#47)
  • Fixed an issue where roll_mean() produced incorrect results when both weights and na.rm = TRUE were used. The weights are now re-normalized after removing NAs. (#23)
  • Fixed an issue where the weighted version of roll_median() ignored na.rm, and associated each weight with the sorted position of a value rather than with the value itself.
  • Fixed an issue where rolling over a matrix with weights sized the output from n rather than from the weights, so each column read past its end and returned undefined values; and an issue where a matrix result with by greater than one was sized as though by were one, leaving rows that were never computed. (#51)
  • Degenerate window geometries are now handled safely: calls with fewer observations than one window return an empty result rather than reading out of bounds (or failing with an opaque error), a window size of zero is rejected rather than corrupting memory, and arrays with three or more dimensions are rejected rather than rolled over their flattened data.
  • The roll_*() functions now warn when n and weights are both supplied and disagree, since weights silently determines the window size. (#39)

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 2.6 min · r-devel-windows-x86_64
Status changes
  • OK13 OK2026-09-08
  • ERROR12 OK, 1 ERROR2026-09-07
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK14 OK2026-04-22
Show 3 earlier changesHide 3 earlier changes
  • ERROR13 OK, 1 ERROR2026-04-18
  • OK14 OK2026-04-01
  • NOTE12 OK, 2 NOTE2026-03-10
Advisories

none known

Documentation

In release 0.4.0
READMEYes · 218 wordsVignettesNoNEWSYes · 100% structured · mentions 0.4.0Citation fileNoWebsiteYes · pkgdown
Help pages
3includes a package overview page
Examples that run
no examples
Exported functions with examples
0%
Documented parameters
100%
Return-value docs
50%
Help pages citing references
0%

Downloads

351.2K
CRAN downloads in the past year
Rank #675 · ~962/day · ~29.3K/mo
Daily download trend is not available in this view yet.
26.7K30 days
80.7K90 days
351.2K1 year
Compare downloads with other packages →
Also on11.3K r2u186 autocran31.7K conda_forge163 c2d4u

Repository

83Stars
14Forks
15Open issues
0Open PRs
1Releases
142Commits
1Commit identities
142 commits · Last activity 2026-09-07 · Default branch at 0.4.0.9000, ahead of CRAN 0.4.0 (checked 2026-10-18)
Responsiveness
How these are sampled
PRs merged (all time)
89%
Median days to close, 50 most recently updated closed issues
231
Median days to close, 50 most recently updated closed PRs
0

Releases over time

2026-09-06 · 02026-09-07 · 1
PracticesBeta

6 development-tooling and community-health practices detected across 3 families in the upstream repository

Checks run against github.com/kevinushey/rcpproll on 2026-10-18.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (3)
pkgdown

GitHub Pages site last deployed 2026-09-07 · The repository has a site deploy workflow

Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-09-06
    Commits: at least 3 crediting it in the message
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
2 external dependencies (excludes base and recommended)

Installing RcppRoll adds no packages beyond those that come with R.

Depends (1)
R >= 2.15.1
Imports (0)
none
LinkingTo (0)
none
Suggests (2)
Enhances (0)
none
Reverse dependencies
24direct
35indirect
Imports 24
Suggested by 3
Show all 27 packagesHide all 27 packages
Depends, Imports or LinkingTo, most downloaded first
Suggests, most downloaded first

People & History

People (1)
Author, Maintainer since 0.1.0 (2013)
Releases (6)

Pick two releases to compare their code metrics.

  • 0.4.0Latest
    record
    2026-09-06 · current release · diff ↗ ·
    added 1 export
    roll_threads
  • R
    R 4.6.0 released · 2026-04-24
  • 0.3.2
    record
    2026-03-28 · diff ↗
  • R
    R 4.5.0 released · 2025-04-11
  • 0.3.1
    record
    2024-07-07 · diff ↗
  • R
    R 4.4.0 released · 2024-04-24
  • R
    R 4.3.0 released · 2023-04-21
  • R
    R 4.2.0 released · 2022-04-22
  • R
    R 4.1.0 released · 2021-05-18
  • R
    R 4.0.0 released · 2020-04-24
  • R
    R 3.6.0 released · 2019-04-26
  • 0.3.0
    record
    2018-06-05 · diff ↗ ·
    removed 3 exports
    get_rollit_source, rollit, rollit_raw
  • R
    R 3.5.0 released · 2018-04-23
  • R
    R 3.4.0 released · 2017-04-21
  • R
    R 3.3.0 released · 2016-05-03
  • R
    R 3.2.0 released · 2015-04-16
Show 5 earlier eventsHide 5 earlier events
  • 0.2.2
    record
    2015-04-05 · diff ↗ ·
    added 16 exports
    roll_maxl, roll_maxr, roll_meanl, roll_meanr, roll_medianl, roll_medianr, roll_minl, roll_minr, roll_prodl, roll_prodr, roll_sdl, roll_sdr, roll_suml, roll_sumr, roll_varl, roll_varr
  • R
    R 3.1.0 released · 2014-04-10
  • R
    R 3.0.0 released · 2013-04-03
  • 0.1.0
    record
    2013-01-15
  • R
    R 2.15.0 released · 2012-03-30

Package metadata

First published
2013-01-15
Total releases
6 / 13 yrs
License
GPL (>= 2) OSI
Minimum R
≥ 2.15.1
Download size
38 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("RcppRoll")
Ushey, K. (2026). RcppRoll: Efficient Rolling / Windowed Operations (Version 0.4.0) [Computer software]. https://doi.org/10.32614/CRAN.package.RcppRoll

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for RcppRoll version 0.4.0 [Data set]. HJJB, LLC. Data release v2026-10-22. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy