Fill with locf and nocb

fill_both(body, idx, order = c("locf", "nocb"))

Arguments

body

[numeric vector]

The body of the vector.

idx

[integer vector]

the index to replace with.

order

[character: "locf"]

Select which filling algorithms will occur first "locf" or "nocb".

Value

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

Examples

leadx(1:4, fill = fill_both)
#> Error in asserts_fill(n, fill): object 'fill_both' not found
leadx(1:4, fill = ~ fill_both(.x,.y, order = "nocb"))
#> Error in fill_both(.x, .y, order = "nocb"): could not find function "fill_both"
lagx(1:4, fill = fill_both)
#> Error in asserts_fill(n, fill): object 'fill_both' not found
lagx(1:4, fill = ~ fill_both(.x,.y, order = "nocb"))
#> Error in fill_both(.x, .y, order = "nocb"): could not find function "fill_both"