nest_fill | R Documentation |
nest_fill()
is used to fill missing values in selected columns of nested data
frames using the next or previous entries in a column of nested data frames.
nest_fill( .data, .nest_data, ..., .direction = c("down", "up", "downup", "updown") )
.data |
A data frame, data frame extension (e.g., a tibble), or a lazy data frame (e.g., from dbplyr or dtplyr). |
.nest_data |
A list-column containing data frames |
... |
< |
.direction |
Direction in which to fill missing values. Currently either "down" (the default), "up", "downup" (i.e. first down and then up) or "updown" (first up and then down). |
nest_fill()
is a wrapper for tidyr::fill()
and maintains the functionality
of fill()
within each nested data frame. For more information on fill()
please refer to the documentation in 'tidyr'.
An object of the same type as .data
. Each object in the column .nest_data
will have the chosen columns filled in the direction specified by .direction
.
Other tidyr verbs:
nest_drop_na()
,
nest_extract()
,
nest_replace_na()
,
nest_separate()
,
nest_unite()
set.seed(123) gm <- gapminder::gapminder %>% mutate(pop = if_else(runif(n()) >= 0.9,NA_integer_,pop)) gm_nest <- gm %>% tidyr::nest(country_data = -continent) gm_nest %>% nest_fill(.nest_data = country_data,pop,.direction = "down")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.