nest_drop_na {nplyr}R Documentation

Drop rows containing missing values in a column of nested data frames

Description

nest_drop_na() is used to drop rows from each data frame in a column of nested data frames.

Usage

nest_drop_na(.data, .nest_data, ...)

Arguments

.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_data to inspect for missing values. If empty, all columns within each dataframe in .nest_data are used.

Details

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'.

Value

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.

See Also

Other tidyr verbs: nest_extract(), nest_fill(), nest_replace_na(), nest_separate(), nest_unite()

Examples

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)

[Package nplyr version 0.2.0 Index]