Nesting your data
In this course, you will work with a collection of economic and social indicators for 77 countries over a period of 52 years. This data is stored in the gapminder
data frame.
In this exercise, you will transform your gapminder
data into a nested data frame by using the first tool needed to build the foundation of tidy machine learning skills: nest()
.
Note: This is a more granular version than the dataset available from the gapminder
package. This version is available in the dslabs
package.
This exercise is part of the course
Machine Learning in the Tidyverse
Exercise instructions
- Take a look at the first six rows of
gapminder
. - Now leverage
group_by()
andnest()
to nest your data frames bycountry
, save this asgap_nested
. - Explore the first six rows of the newly created data frame
gap_nested
, note the new complex column data containing tibbles.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Explore gapminder
head(___)
# Prepare the nested data frame gap_nested
library(tidyverse)
gap_nested <- gapminder %>%
group_by(___) %>%
___()
# Explore gap_nested
head(___)