1. Faceting
You've learned to use color
2. Plot Life Expectancy vs GDP
to distinguish the five continents within your scatterplot. Now you'll learn about another way to explore your data in terms of this kind of categorical variable.
3. Faceting
ggplot2 lets you divide your plot into subplots to get one smaller graph for each continent: Africa, the Americas, and so on. This is called faceting, and it's another powerful way to communicate relationships within your data.
You facet a plot by adding another option, with a +, to the end of your code, after geom_point and scale_x_log10. You add facet underscore wrap, then "tilde continent" within the parentheses. In R, the tilde symbol typically means "by", meaning that we're splitting the plot by continent, and you can usually find it on the upper left of your keyboard. This tells ggplot2 to divide the data into subplots based on the continent variable. Faceting is a powerful tool, and in
4. Faceting Plots
the exercises you'll see how you can use faceting not just to compare among continents, but to compare between all of the years in our dataset.
5. Let's practice!