Learn R Programming

runner (version 0.2.1)

whicht_run: Running which-true function

Description

whicht_run checks which element has value TRUE within specified running window.

Usage

whicht_run(x, k = 0L, which = "last", na_rm = TRUE, na_pad = FALSE,
  idx = 0L)

Arguments

x

input logical vector where running which-true is calculated.

k

Running window size. By default window size equals length(x). Allow varying window size specified by vector of length(x)

which

specifies whether "first" or "last" index is returned.

na_rm

logical (default na_rm=TRUE) - if TRUE NA are replaced by last observed minimum prior to element.

na_pad

logical (default na_pad=FALSE) - if TRUE first k-results will be filled by NA. If k is not specified na_pad=F by default.

idx

an optional integer vector containing indexes numbers of observation.

Value

numeric vector of length equals length of x containing running index in k-long window.

Examples

Run this code
# NOT RUN {
x <- c( NA, FALSE, TRUE, NA, TRUE, FALSE, TRUE, TRUE)
whicht_run( x, k=2, na_rm=TRUE, na_pad=FALSE )
# }

Run the code above in your browser using DataLab