gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent)
# a summary applied to an ungrouped tbl returns a single row
gm_nest %>%
nest_summarise(
country_data,
n = n(),
median_pop = median(pop)
)
# usually, you'll want to group first
gm_nest %>%
nest_group_by(country_data, country) %>%
nest_summarise(
country_data,
n = n(),
median_pop = median(pop)
)
Run the code above in your browser using DataLab