Learn R Programming

cycleRtools (version 1.1.1)

rollmean_: Rolling average smoothing.

Description

Smooth data with a right-aligned (zero-padded) rolling average.

Usage

rollmean_(x, window, ema, narm)
rollmean_smth(data, column, smth.pd, deltat = NULL, ema = FALSE, character.only = FALSE)

Arguments

x
numeric; values to be rolled over.
window
numeric; size of the rolling window in terms of elements in x.
ema
logical; should the moving average be exponentially weighted?
narm
logical; should NAs be removed?
data
a dataset of class cycleRdata.
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).
deltat
the sampling frequency of data in seconds per sample; typically 0.5 or 1. If NULL, this is estimated.
character.only
are column name arguments given as character strings? A backdoor around non-standard evaluation.

Value

a vector of the same length as the data[, column].

Details

rollmean_ is the core Rcpp function, which rolls over elements in x by a window given in window; optionally applying exponential weights and/or removing NAs. rollmean_smth is a wrapper for rollmean_ that only has a method for cycleRdata objects. The latter will pre-process the data and permits what is effectively the window argument being given in time units.

Examples

Run this code
## Not run: 
# data(ridedata)
# 
# ## Smooth power data with a 30 second moving average.
# rollmean_smth(ridedata, power.W, 30)
# 
# ## Or use an exponentially weighted moving average.
# rollmean_smth(ridedata, power.W, 30, ema = TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab