Faceting the time series

Now you'll take a look at six countries. While in the previous exercise you used color to represent distinct countries, this gets a little too crowded with six.

Instead, you will facet, giving each country its own sub-plot. To do so, you add a facet_wrap() step after all of your layers.

This exercise is part of the course

Case Study: Exploratory Data Analysis in R

View Course

Exercise instructions

  • Create a filtered version that contains these six countries called filtered_6_countries.
  • Use the filtered dataset (containing summarized data for six countries) to create a plot with one facet for each country.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Vector of six countries to examine
countries <- c("United States", "United Kingdom",
               "France", "Japan", "Brazil", "India")

# Filtered by_year_country: filtered_6_countries


# Line plot of % yes over time faceted by country
___(filtered_6_countries, ___) ___
  ___
  ___