Generic functions for computing rolling means, maximums, medians, and sums of ordered observations.
Usage
rollmean(x, k, fill = if (na.pad) NA, na.pad = FALSE,
align = c("center", "left", "right"), ...)
rollmax(x, k, fill = if (na.pad) NA, na.pad = FALSE,
align = c("center", "left", "right"), ...)
rollmedian(x, k, fill = if (na.pad) NA, na.pad = FALSE,
align = c("center", "left", "right"), ...)
rollsum(x, k, fill = if (na.pad) NA, na.pad = FALSE,
align = c("center", "left", "right"), ...)
rollmeanr(..., align = "right")
rollmaxr(..., align = "right")
rollmedianr(..., align = "right")
rollsumr(..., align = "right")
Arguments
x
an object (representing a series of observations).
k
integer width of the rolling window. Must be odd for rollmedian.
fill
a three-component vector or list (recycled otherwise) providing
filling values at the left/within/to the right of the data range.
See the fill argument of na.fill for details.
na.pad
deprecated. Use fill = NA instead of na.pad = TRUE.
align
character specifying whether the index of the result
should be left- or right-aligned or centered (default) compared
to the rolling window of observations.
...
Further arguments passed to methods.
Details
These functions compute rolling means, maximums, medians, and sums respectively
and are thus similar to rollapply but are
optimized for speed.
Currently, there are methods for "zoo" and "ts" series and
default methods. The default method of rollmedian
is an interface to runmed.
The default method of rollmean does not handle inputs that contain
NAs. In such cases, use rollapply instead.
Value
An object of the same class as x with the rolling mean/max/median/sum.