NA
values forwards and backwardsFill NA
values forwards and backwards
f_fill(
data,
...,
.by = NULL,
.cols = NULL,
.direction = c("forwards", "backwards"),
.fill_limit = Inf,
.new_names = "{.col}"
)
A data frame with NA
values filled forward or backward.
A data frame.
Cols to fill NA
values specified through tidyselect
notation.
If left empty all cols are used by default.
Cols to group by for this operation.
Specified through tidyselect
.
(Optional) alternative to ...
that accepts
a named character vector or numeric vector.
If speed is an expensive resource, it is recommended to use this.
Which direction should NA
values be filled?
By default, "forwards" (Last-Observation-Carried-Forward) is used.
"backwards" is (Next-Observation-Carried-Backward).
The maximum number of consecutive NA
values to fill.
Default is Inf
.
A name specification for the names of filled variables.
The default "{.col}"
replaces the given variables with the imputed ones.
New variables can be created alongside the originals if we give a different
specification, e.g.
.new_names = "{.col}_imputed"
.
This follows the specification of dplyr::across
if .fns
were an empty
string ""
.