Learn R Programming

A dedicated Slack channel has been created for announcements, support and to help build a community of practice around this open source package. You may request an invitation to join from jonathan.callahan@dri.com.

MazamaRollUtils

A suite of compiled functions calculating rolling mins, means,
maxes and other statistics. This package is designed to meet the needs of
data processing systems for environmental time series.

Background

Analysis of time series data often involves applying "rolling" functions to calculate, e.g. a "moving average". These functions are straightforward to write in any language and it makes sense to have C++ versions of common rolling functions available to R as they dramatically speed up calculations. Several packages exist that provide some version of this functionality:

core R package with a specific data model

rolling functions for basic statistics

Our goal in creating a new package of C++ rolling functions is to build up a suite of functions useful in environmental time series analysis. We want these functions to be available in a neutral environment with no underlying data model. The functions are as straightforward to use as is reasonably possible with a target audience of data analysts at any level of R expertise.

Installation

Install from CRAN with:

install.packages('MazamaRollUtils')

Install the latest version from GitHub with:

devtools::install_github("MazamaScience/MazamaRollUtils")

Examples

library(MazamaRollUtils)

# Example air quality time series
t <- example_pm25$datetime
x <- example_pm25$pm25

plot(t, x)
lines(t, roll_max(x, width = 12), col = 'salmon')
lines(t, roll_min(x, width = 12), col = 'light blue')

This project is supported by Mazama Science.

Copy Link

Version

Install

install.packages('MazamaRollUtils')

Monthly Downloads

226

Version

0.1.4

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Jonathan Callahan

Last Published

May 9th, 2025

Functions in MazamaRollUtils (0.1.4)

example_pm25

Example timeseries dataset
roll_mean

Roll Mean
roll_prod

Roll Product
roll_min

Roll Min
roll_hampel

Roll Hampel
roll_max

Roll Max
roll_var

Roll Variance
roll_MAD

Roll MAD
roll_sd

Roll Standard Deviation
findOutliers

Outlier Detection with a Rolling Hampel Filter
roll_sum

Roll Sum
roll_median

Roll Median
MazamaRollUtils-package

Mazama Science Rolling Utilities