The goal of tbrf is to provide time-window based rolling statistical functions. The package differs from other rolling statistic packages because the intended use is for irregular measured data. Althogh tbrf can be used to apply statistical functions to regularly sampled data, zoo, RcppRoll, and other packages provide fast, efficient, and rich implementations of rolling/windowed functions.

An appropriate example case is water quality data that is measured at irregular time intervals. Regulatory compliance is often based on a statistical average measure or exceedance probability applied to all samples collected in the previous \(n\)-years. For each row of data, tbrf functions select previous observations in the time windows specified by the user and applies the statistical function.


tbrf is available on CRAN:

The development version is maintained on github and can be installed as:

Available Functions

  • tbr_binom: Rolling binomal probability with confidence intervals.

  • tbr_gmean: Rolling geometric mean with confidence intervals.

  • tbr_mean: Rolling mean with confidence intervals.

  • tbr_median: Rolling median with confidence intervals.

  • tbr_misc: Accepts user specified function.

  • tbr_sd: Rolling standard deviation.

  • tbr_sum: Rolling sum.


Core functions include five arguments:

.tbl = dataframe used by the function

x = column containing the values to calculate the statistic on

tcolumn = formatted date-time or date column

unit = character indicating the time unit used, one of "years", "months", "weeks", "days", "hours", "minutes", "seconds"

n = numeric, indicating the window length

Additional arguments for calculating confidence intervals in tbr_gmean, tbr_mean, and tbr_median are passed to boot and

Parallel Processing

Confidence Intervals in tbr_gmean, tbr_mean, and tbr median are calculated using boot::boot_ci. If you do not need confidence intervals, calculation times are substantially shorter. parallel, ncores, and cl arguments are passed to boot and can improve computation times. See ?boot for more details on parallel operations. An example for parallel processing in Windows is shown below: