Exercise

Aggregating data

Aggregation is the process of reducing the sampling frequency of a time series and is important for understanding patterns within the data, allowing for cleaner visualization and interpretation. Especially if the temporal resolution is high – data sampled every hour or minute – it can be difficult to interpret the data or spot patterns, leading to a need for aggregation.

Here, you'll take a time series, hourly_temperature, containing hourly temperature readings from a town in the United States, and aggregate it to different levels.

hourly_temperature, xts, and ggplot2 are loaded for you.

Instructions 1/4

undefined XP
  • 1
    • Autoplot the hourly_temperature time series with the y-axis label "Degrees Celsius".
  • 2
    • Using the apply-dot functions, aggregate hourly_temperature to the daily average.
  • 3
    • Aggregate hourly_temperature to find the weekly maximum, and autoplot with the 'light' theme and the same y-axis label.
  • 4
    • Aggregate hourly_temperature to find the monthly median and plot with the theme and y-axis label from Step 1.