We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Firefox.

Creating a simple line graph

ggplot(___) + 
    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).

ggplot(gapminder_japan) + 
    mapping = aes(x = year, y = lifeExp)