# Daily precipitation data
daily_prcp <- data.frame(
date = seq(as.Date("2000-01-01"), as.Date("2002-12-31"), by = "day"),
rainfall = pmax(0, rgamma(1096, shape = 0.5, scale = 10))
)
# Calculate number of days with precipitation \eqn{\geq} 10mm
calculate_R10mm(
df = daily_prcp,
frequency = "daily",
time_col = "date",
prcp_col = "rainfall"
)
# With custom threshold (15mm instead of 10mm)
calculate_R10mm(
df = daily_prcp,
frequency = "daily",
time_col = "date",
prcp_col = "rainfall",
threshold = 15
)
Run the code above in your browser using DataLab