Learn R Programming

cycleRtools (version 1.0.0)

rollmean_smth: Smooth a column of a dataset.

Description

Smooth data with a right-aligned (zero-padded) rolling average. This is intended for time-based smoothing - e.g. a 30-second moving average. Hence, as rolling operations are performed row-wise in in the interest of efficiency, the data must first be made time-uniform by row. Hence, this is done via uniform by the first column of the data; thus allowing the column to be smoothed.

Usage

rollmean_smth(data, column, smth.pd, ema = FALSE, delta = NULL,
  verbose = TRUE, .uniform = FALSE)

Arguments

data
a data.frame or matrix object to use for smoothing. The data is made uniform on the basis of the first column.
column
the column name of the data to be smoothed, needn't be quoted.
smth.pd
numeric; the time period over which to smooth (seconds).
ema
should the moving average be exponentially weighted?
delta
the incremement with which to initially make the data uniform. If NULL (default) a best estimate is used.
verbose
should messages be printed to the console?
.uniform
are the rows of the data already uniform?

Value

  • a vector of the same length as the column.

Examples

Run this code
data(cycling_data)
# Smooth power data with a 30 second moving average.
rollmean_smth(cycling_data, power.W, 30)
# Or alternatively, use an exponentially weighted moving average.
rollmean_smth(cycling_data, power.W, 30, ema = TRUE)

Run the code above in your browser using DataLab