fill_locf: Fill with "Last Observation Carried Forward"

Description Usage Arguments Value Examples

View source: R/fill.R

Description

Fill with "Last Observation Carried Forward"

Usage

1
fill_locf(body, idx, fail = NA)

Arguments

body

[numeric vector]

The body of the vector.

idx

[integer vector]

the index to replace with.

fail

[numeric(1) or numeric vector: fill]

In case it fails to fill some values.

Value

Returns a vector with the same class and attributes as the input vector.

Examples

1
2
3
4
5
6
x <- c(5,3,2,2,5)
lagx(x, n = 2, fill = fill_locf)
leadx(x, n = 2, fill = fill_locf)

lagx(x, n = 2, fill = fill_nocb)
leadx(x, n = 2, fill = fill_nocb)

transx documentation built on Nov. 27, 2020, 5:08 p.m.