1. Learn
  2. /
  3. Courses
  4. /
  5. Manipulating Time Series Data in R

Exercise

Rolling window functions

Rolling averages can be used to 'smooth out' noisy data, where you want to show how quickly or slowly the values change on average.

In this exercise, you'll take the time series us_temperatures, containing hourly temperature readings from three cities in the United States. Using rolling windows, you'll calculate rolling statistics – a mean, maximum, and median – with different window widths to see the effects of changing the window size!

Important to note is that rolling medians require an odd window width!

The us_temperatures time series and the zoo and ggplot2 packages are available to you.

Instructions 1/3

undefined XP
  • 1
    • Create a right-aligned, 12-hour rolling average of us_temperatures and observe its plot.
  • 2
    • Create a left-aligned, 24-hour rolling maximum of us_temperatures and plot the result.
  • 3
    • Create a center-aligned, 99-hour rolling median of us_temperatures and plot observe the resulting plot.