Learn R Programming

tidyextreme (version 1.0.0)

calculate_Rx1day: Calculate maximum 1-day precipitation (Rx1day)

Description

Calculates the annual maximum 1-day precipitation amount, following ETCCDI definition Rx1day.

Usage

calculate_Rx1day(
  df,
  frequency = "daily",
  time_col = NULL,
  prcp_col = NULL,
  precip_col = NULL,
  min_valid_years = 1
)

Value

A data.frame with columns: year, Rx1day

Arguments

df

Data frame with precipitation data

frequency

Temporal frequency: "daily" or "hourly" (string)

time_col

Name of the time column (string). For daily frequency, the column should be of class Date or a string in the format YYYY-MM-DD. For hourly frequency, the column should be of class POSIXct or a string in the format YYYY-MM-DD HH:MM:SS.

prcp_col

Name of precipitation column (daily data) (string)

precip_col

Name of precipitation column (hourly data) (string)

min_valid_years

Minimum years with valid data (default: 1)

Examples

Run this code
# 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_Rx1day(
  df = daily_prcp,
  frequency = "daily",
  time_col = "date",
  prcp_col = "rainfall"
)

Run the code above in your browser using DataLab