nest_drop_na | R Documentation |
nest_drop_na()
is used to drop rows from each data frame in a column of
nested data frames.
nest_drop_na(.data, .nest_data, ...)
.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 |
... |
Columns within |
nest_drop_na()
is a wrapper for tidyr::drop_na()
and maintains the functionality
of drop_na()
within each nested data frame. For more information on drop_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 rows dropped according to the presence of NAs.
Other tidyr verbs:
nest_extract()
,
nest_fill()
,
nest_replace_na()
,
nest_separate()
,
nest_unite()
gm <- gapminder::gapminder # randomly insert NAs into the dataframe & nest set.seed(123) gm <- gm %>% mutate(pop = if_else(runif(nrow(gm)) >= 0.9, NA_integer_, pop)) gm_nest <- gm %>% tidyr::nest(country_data = -continent) # drop rows where an NA exists in column `pop` gm_nest %>% nest_drop_na(.nest_data = country_data,pop)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.