climatic_extremes: Calculate extremes from climatic data

View source: R/climatic_extremes.R

climatic_extremesR Documentation

Calculate extremes from climatic data

Description

climatic_extremes returns a data table displaying the minimum and/or maximum values for elements in a given time period. This can be provided by station.

Usage

climatic_extremes(
  data,
  date_time,
  elements,
  station = NULL,
  year = NULL,
  month = NULL,
  dekad = NULL,
  pentad = NULL,
  to = c("hourly", "daily", "pentad", "dekadal", "monthly", "annual-within-year",
    "annual", "longterm-monthly", "longterm-within-year", "station", "overall"),
  by = NULL,
  doy = NULL,
  doy_first = 1,
  doy_last = 366,
  max_val = TRUE,
  min_val = FALSE,
  first_date = FALSE,
  n_dates = FALSE,
  last_date = FALSE,
  na_rm = FALSE,
  na_prop = NULL,
  na_n = NULL,
  na_consec = NULL,
  na_n_non = NULL,
  names = "{.fn}_{.col}"
)

Arguments

data

data.frame The data.frame to calculate from.

date_time

Date The name of the date column in data.

elements

character The name of the elements column in data to apply the function to.

station

character(1) The name of the station column in data, if the data are for multiple station.

year

character(1) The name of the year column in data.

month

character(1) The name of the month column in data.

dekad

character(1) The name of the dekad column in data.

pentad

character(1) The name of the pentad column in data.

to

character(1) The date-time format to put the data into.

by

character The name of columns in data to group the summary data by.

doy

character(1) The name of the day of the year (1-366) column in data. If NULL it will be created using lubridate::year(data[[doy]]).

doy_first

integer(1) The first day of the year.

doy_last

integer(1) The last day of the year.

max_val

logical(1) If TRUE the extreme maximum is calculated.

min_val

logical(1) If TRUE the extreme minimum is calculated.

first_date

logical(1) If TRUE the first instance of date_time when the value equals the summary value is included. Generally only used for extreme summaries i.e. first date_time when the maximum occurred.

n_dates

logical(1) If TRUE the number of date_time points when the value equals the summary value is included. Generally only used for extreme summaries i.e. number of days in which the minimum occurred.

last_date

logical(1) If TRUE the last instance of date_time when the value equals the summary value is included. Generally only used for extreme summaries i.e. last date_time when the maximum occurred.

na_rm

logical(1) If TRUE all na_ parameters are ignored and missing values are removed. If FALSE missing values are not removed unless any na_ parameters are specified.

na_prop

integer(1) Max proportion of missing values allowed

na_n

integer(1) Max number of missing values allowed

na_consec

integer(1) Max number of consecutive missing values allowed

na_n_non

integer(1) Min number of non-missing values required

names

Format of column names. Passed to .names in dplyr::across

Value

A summary data frame containing minimum/maximum values for element(s).

Examples

# Run example for a subset of the data
daily_niger_1 <- daily_niger %>% dplyr::filter(year > 1970)
# create a data frame displaying the min and max values for tmin/tmax for each day and station
climatic_extremes(data = daily_niger_1, date_time = "date", elements = c("tmin", "tmax"),
                  max_val = TRUE, min_val = TRUE,
                  station = "station_name", na_rm = TRUE)

IDEMSInternational/cdms.products documentation built on July 7, 2023, 10:13 a.m.