Visualizing median GDP per capita over time
A line plot is useful for visualizing trends over time. In this exercise, you'll examine how the median GDP per capita has changed over time.
Deze oefening maakt deel uit van de cursus
Introduction to the Tidyverse
Oefeninstructies
- Use
group_by()andsummarize()to find the median GDP per capita within each year, calling the output columnmedianGdpPercap. Use the assignment operator<-to save it to a dataset calledby_year. - Use the
by_yeardataset to create a line plot showing the change in median GDP per capita over time. Be sure to useexpand_limits(y = 0)to include 0 on the y-axis.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
library(gapminder)
library(dplyr)
library(ggplot2)
# Summarize the median gdpPercap by year, then save it as by_year
# Create a line plot showing the change in medianGdpPercap over time