runstat {IRanges} | R Documentation |
The runsum
, runmean
, runwtsum
, runq
functions
calculate the sum, mean, weighted sum, and order statistics for fixed width
running windows.
runsum(x, k, endrule = c("drop", "constant"), ...) runmean(x, k, endrule = c("drop", "constant"), ...) runwtsum(x, k, wt, endrule = c("drop", "constant"), ...) runq(x, k, i, endrule = c("drop", "constant"), ...)
x |
The data object. |
k |
An integer indicating the fixed width of the running window. Must be
odd when |
wt |
A numeric vector of length |
i |
An integer in [0, k] indicating which order statistic to calculate. |
endrule |
A character string indicating how the values at the beginning and the end (of the data) should be treated.
|
... |
Additional arguments passed to methods. Specifically,
|
The runsum
, runmean
, runwtsum
, and runq
functions provide efficient methods for calculating the specified
numeric summary by performing the looping in compiled code.
An object of the same class as x
.
P. Aboyoun and V. Obenchain
runmed
, Rle-class, RleList-class
x <- Rle(1:10, 1:10) runsum(x, k = 3) runsum(x, k = 3, endrule = "constant") runmean(x, k = 3) runwtsum(x, k = 3, wt = c(0.25, 0.5, 0.25)) runq(x, k = 5, i = 3, endrule = "constant") ## Missing and non-finite values x <- Rle(c(1, 2, NA, 0, 3, Inf, 4, NaN)) runsum(x, k = 2) runsum(x, k = 2, na.rm = TRUE) runmean(x, k = 2, na.rm = TRUE) runwtsum(x, k = 2, wt = c(0.25, 0.5), na.rm = TRUE) runq(x, k = 2, i = 2, na.rm = TRUE) ## max value in window