1. Learn
  2. /
  3. Courses
  4. /
  5. Reshaping Data with tidyr

Connected

Exercise

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.

Instructions

100 XP
  • 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.