CommencerCommencer gratuitement

Zero Olympic medals

Since 1896, athletes from all over the world have been competing in the modern Olympic games. You've been given a dataset (medal_df) with observations for all medals won by athletes from the 10 most successful countries in Olympic history. You want to create a visual with the number of medals won per country (team) per year. However, since not all countries won medals each year, you'll have to introduce zero values before you can make an accurate visual.

Olympic flag

The ggplot2 and dplyr packages have been pre-loaded for you. In step 2 and 3 the scale_color_brewer() function is used to color lines in the plot with a palette that makes it easier to distinguish the different countries.

Cet exercice fait partie du cours

Reshaping Data with tidyr

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

medal_df %>% 
  # Count the medals won per team and year
  ___(___, ___, name = "n_medals")
Modifier et exécuter le code