fill_nocb: Fill with "Next observation carried backwards"

Description Usage Arguments Value Examples

View source: R/fill-functions.R

Description

Maturing lifecycle

Usage

1
fill_nocb(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
 7
 8
 9
10
x <- c(5,3,2,2,5)
leadx(x, n = 2, fill = fill_locf)

xlen <- length(x)
n <- 2
n <- pmin(n, xlen)
idx <- (xlen - n + 1):xlen
body <- x[-seq_len(n)]
fill_nocb(body, idx, NA)
fill_both(body, idx, first = "nocb")

kvasilopoulos/transx documentation built on Jan. 26, 2021, 6:14 p.m.