Session Ready
Exercise

Gather & plot

In a previous frustrating exercise working with untidy data, we attempted to visualize viewers per episode across series with the untidy ratings data.

Here is the plot we wanted to create. To make it, we'll tidy the data, then use row_number() from the dplyr package to create a continuous episode count variable, such that episode 1 from series 1 will have a value of 1, episode 1 from series 2 will have a value of 7, and so on. This new variable will be mapped onto the x-axis using ggplot2.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Gather all columns but series. Name the key episode and the value viewers_7day. For plotting, store the key values as a factor variable to preserve the original ordering of the episodes, and remove rows that are NA.