Fill with "Next observation carried backwards"
fill_nocb(body, idx, fail = NA)
body |
The body of the vector. |
---|---|
idx |
the index to replace with. |
fail |
In case it fails to fill some values. |
Returns a vector with the same class and attributes as the input vector.
#> [1] 2 2 5 5 5xlen <- length(x) n <- 2 n <- pmin(n, xlen) idx <- (xlen - n + 1):xlen body <- x[-seq_len(n)] fill_nocb(body, idx, NA)#> [1] NA NA#> Error in fill_both(body, idx, order = "nocb"): could not find function "fill_both"