View source: R/nest_replace_na.R
nest_replace_na | R Documentation |
nest_replace_na()
is used to replace missing values in selected columns of
nested data frames using values specified by column.
nest_replace_na(.data, .nest_data, replace, ...)
.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 |
replace |
A list of values, with one value for each column in that has |
... |
Additional arguments for |
nest_replace_na()
is a wrapper for tidyr::replace_na()
and maintains the functionality
of replace_na()
within each nested data frame. For more information on replace_na()
please refer to the documentation in 'tidyr'.
An object of the same type as .data
. Each object in the column .nest_data
will have NAs replaced in the specified columns.
Other tidyr verbs:
nest_drop_na()
,
nest_extract()
,
nest_fill()
,
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_replace_na(.nest_data = country_data, replace = list(pop = -500))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.