Exercise

Plotting an aggregated time series with ggplot2

Aggregating data allows you to uncover general patterns and trends in your data, but can often lead to a loss of information and context. However, using methods from ggplot2 can give some context back to the aggregated data.

In this exercise, you'll practice plotting weekly aggregated temperature readings, weekly_avg, alongside the original, unaggregated time series, hourly_temperature, which represents temperature readings for an entire year, sampled every hour.

The time series hourly_temperature and weekly_avg, as well as the ggplot2 and zoo packages are available to you.

Instructions

100 XP
  • Using the ggplot() function, plot the hourly_temperature time series as a line plot.

  • Add the y-axis label "Degrees Celsius" and the title "Temperature Readings".

  • Complete the second call to geom_line() and aes() to overlay the weekly_avg time series on your plot.

  • Change the line color of the weekly aggregate to red and the size of the line to 2.