Creating a simple line graph

ggplot(___) + 
  geom_line(
    mapping = aes(x = ___, y = ___, 
                  group = ___, 
                  color = ___)
)
View Interactive Version

Japan is among the countries with the highest life expectancy. Using the gapminder_japan dataset we determine how the life expectancy in Japan has developed over time. We need to:

  1. Specify the dataset within ggplot()
  2. Define the geom_line() plot layer
  3. Map the year to the x-axis and the life expectancy lifeExp to the y-axis with the aes() function

Note that the ggplot2 library needs to be loaded first with library(ggplot2).

Input
library(ggplot2)
ggplot(gapminder_japan) + 
  geom_line(
    mapping = aes(x = year, y = lifeExp)
)
Create a line graph with ggplot