---
layout: post
title: "Using the dplyr lag and lead function to find the length of drought (CC245)"
blurb: "Is Ann Arbor getting more or less droughty with time?"
author: "PD Schloss"
date: 2022-09-06 11:00
comments: false
youtube: uNQ3fwnUQsE
start_hash: 3d806f8b716c70956bff039feb623cdf1e250084
end_hash: 13af74b37578e30f308550b687fa6b6d5d0813bd
---

The `lag` and `lead` functions from dplyr allow you to create columns that are offset from the reference column by one or more rows. In this Code Club, Pat responds to a commenter's question to calculate the number of days between precipitation events to see if the length of drought is increasing or decreasing over time. Pat will address these questions using local weather data downloaded from NOAA in RStudio with a lot of help from the tidyverse and the bench R package

<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 }})
