gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent)
# apply a filter
gm_nest %>%
nest_filter(country_data, year > 1972)
# apply multiple filters
gm_nest %>%
nest_filter(country_data, year > 1972, pop < 10000000)
# apply a filter on grouped data
gm_nest %>%
nest_group_by(country_data, country) %>%
nest_filter(country_data, pop > mean(pop))
Run the code above in your browser using DataLab