Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Manipulating Time Series Data in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create and plot the rolling average
___(___) %>%
  autoplot() + 
  theme_light() + 
  labs(y = "Degrees Celsius")
Code bewerken en uitvoeren