powered by
Fill with "Next observation carried backwards"
fill_nocb(body, idx, fail = NA)
[numeric vector]
The body of the vector.
[integer vector]
the index to replace with.
[numeric(1) or numeric vector: fill]
In case it fails to fill some values.
Returns a vector with the same class and attributes as the input vector.
# NOT RUN { 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_locf(body, idx, NA) # }
Run the code above in your browser using DataLab