runstat {IRanges}R Documentation

Fixed width running window summaries across vector-like objects

Description

The runsum, runmean, runwtsum, runq functions calculate the sum, mean, weighted sum, and order statistics for fixed width running windows.

Usage

  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"))

Arguments

x The data object.
k An integer indicating the fixed width of the running window. Must be odd when endrule == "constant".
wt A numeric vector of length k that provides the weights to use.
i An integer 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.
"drop"
do not extend the running statistics to be the same length as the underlying vectors;
"constant"
copies running statistic to the first values and analogously for the last ones making the smoothed ends constant;

Details

The runsum, runmean, runwtsum, and runq functions provide efficient methods for calculating the specified numeric summary by performing the looping in compiled code.

Value

An object of the same class as x.

Author(s)

P. Aboyoun

See Also

runmed, Rle-class, RleList-class

Examples

  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")

[Package IRanges version 1.6.16 Index]