---
layout: post
title: "Creating a sliding window with the slider R package to quantify the level of drought (CC239)"
blurb: "That wasn't even the dryest summer!"
author: "PD Schloss"
date: 2022-08-15 11:00
comments: false
youtube: 1X9GGgOPKcI
start_hash: df5baf7e7de84de7bfbf468296067e3c00ccafac
end_hash: 4a631e9ffd5db0da29bc65c768aade0dc6e36bcf
---

The slider R package has a great set of `slide` functions to bulid sliding windows across a tidy dataframe. The syntax is very similar to the `map` functions from purrr. Watch as Pat shows how to quantify the amount of drought using the `slide` and `slide_dbl` functions from slider. He'll also compare those functions to the `lag` and `lead` fuctions from dplyr. Finally, he makes a plot showing when droughts have occurred over the past 130 years in Southeastern Michigan. He does all this using local weather data downloaded from NOAA in RStudio with a lot of help from the tidyverse


<iframe style="margin: 0 auto;display:block;" width="560" height="315" src="https://www.youtube.com/embed/{{ page.youtube }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>


## Code

You can browse the state of the repository at the
* [beginning of the episode](https://github.com/riffomonas/climate_viz/tree/{{ page.start_hash }})
* [end of the episode](https://github.com/riffomonas/climate_viz/tree/{{ page.end_hash }})
