Using the dplyr lag and lead function to find the length of drought (CC245)

September 6, 2022 • PD Schloss • 1 min read

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

Code

You can browse the state of the repository at the