Skip to content

Instantly share code, notes, and snippets.

@oousmane
Last active May 9, 2026 15:32
Show Gist options
  • Select an option

  • Save oousmane/d0f8a476590de40a6430bbf6b6edeeef to your computer and use it in GitHub Desktop.

Select an option

Save oousmane/d0f8a476590de40a6430bbf6b6edeeef to your computer and use it in GitHub Desktop.
This piece of code let you compute season length using definition of onset, cessation valid for sahelian region
# set up
pak::pak("YODAdam/ClimSeasonR")
library(tidyverse)
library(ClimSeasonR)
# read and clean daily data for multiple stations
data<-readxl::read_excel("~/Downloads/rain.xls",skip = 2) %>%
janitor::clean_names()
# compute season length, for a set of stations
data %>%
group_by(name) %>%
reframe(
onset = dt_start(
x = value,
early = 91,
maxDrySpell_aft = 10
),
cessation = end_season(
x=value
)
) %>%
mutate(season_length = cessation-onset+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment