ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Reshaping Data with tidyr

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

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 ~ .)
Editar y ejecutar código