Join the two data sets together
In the video, you have learned that the inner_join()
function of dplyr
needs to be given a "key" on which two data frames are joined. Actually, multiple keys that need to match can be specified. In this first exercise, you are going to join two data sets by two keys. The data frames ilo_hourly_compensation
and ilo_working_hours
are already loaded for you and are available in your workspace.
This course touches on a lot of concepts you may have forgotten, so if you ever need a quick refresher, download the tidyverse Cheat Sheet and keep it handy!
This exercise is part of the course
Communicating with Data in the Tidyverse
Exercise instructions
- Combine both ILO data frames
ilo_hourly_compensation
andilo_working_hours
using theinner_join()
function ofdplyr
. - Join both data frames by the variables
"country"
and"year"
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Join both data frames
ilo_data <- ilo_hourly_compensation %>%
___(___, by = c(___, ___))
# Count the resulting rows
ilo_data %>%
count()
# Examine ilo_data
ilo_data