Add facets to the plot
Here, you'll leverage facet_grid()
to add horizontal facets for 1996 and 2006 each, as detailed in the video.
When using facet_grid()
, it is good practice to specify the arrangement of plots with a named argument: rows = ...
or cols = ...
. This helps to avoid confusion since the facet_grid()
function takes many other arguments.
Este exercício faz parte do curso
Communicating with Data in the Tidyverse
Instruções do exercício
- Use
facet_grid()
with the right argument to generate two separate scatter plots that are arranged horizontally. - The left plot should show the data for the year 1996 while the year 2006 should be shown on the right side.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Again, you save the plot object into a variable so you can save typing later on
ilo_plot <- ggplot(ilo_data, aes(x = working_hours, y = hourly_compensation)) +
geom_point() +
labs(
x = "Working hours per week",
y = "Hourly compensation",
title = "The more people work, the less compensation they seem to receive",
subtitle = "Working hours and hourly compensation in European countries, 2006",
caption = "Data source: ILO, 2017"
) +
# Add facets here
___(___)
ilo_plot