Learn R Programming

runner (version 0.3.0)

window_run: List of running windows

Description

Creates list of windows

Usage

window_run(x, k = integer(1), lag = integer(1), idx = integer(0),
  na_pad = FALSE)

Arguments

x

Vector of any type

k

integer vector or single value denoting size of the running window. If k is a single value then window size is constant for all elements, otherwise if length(k) == length(x) different window size for each element.

lag

integer vector or single value denoting window lag. If lag is a single value then window lag is constant for all elements, otherwise if length(lag) == length(x) different window size for each element. Negative value shifts window forward.

idx

date or integer an optional integer vector containing index of observation. If specified then k and lag are depending on idx. Length of idx should be equal of length x

na_pad

logical single value (default na_pad=FALSE) - if TRUE calculation on incomplete window will return NA. Incomplete window is when some parts of the window are out of range

Examples

Run this code
# NOT RUN {
window_run(1:10, k = 3, lag = -1)
window_run(letters[1:10], k = c(1, 2, 2, 4, 5, 5, 5, 5, 5, 5))
# }

Run the code above in your browser using DataLab