Get startedGet started for free

Olympic medals per continent

You want to compare Olympic performance of athletes per continent over time, both on the winter and summer Olympics. You've been given a dataset medal_df with the average number of medals won per participant of each continent since 1928. You'll complete this data to introduce zero values for years where a continent did not win any medals.

Olympic flag

The ggplot2 package has been pre-loaded for you.

This exercise is part of the course

Reshaping Data with tidyr

View Course

Exercise instructions

  • Complete the dataset so that each continent has a medals_per_participant value at each Olympic event. Missing values should be filled with zeros.
  • Nest the season and year variables using the nesting() function, since the summer and winter Olympics don't occur in the same years.
  • Use ggplot() to create a line plot with the medals_per_participant per year, color the plot by continent.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

medal_df %>% 
  # Give each continent an observation at each Olympic event
  complete(
    ___, 
    ___, 
    fill = ___(___ = ___)
  ) %>%
  # Plot the medals_per_participant over time, colored by continent
  ggplot(___) +
  ___ +
  facet_grid(season ~ .)
Edit and Run Code