calc_annual_anomaly: Calculate annual anomaly

View source: R/anomaly.R

calc_annual_anomalyR Documentation

Calculate annual anomaly

Description

Calculate annual anomaly

Usage

calc_annual_anomaly(x, year, period = NULL, max_missing = 0.2,
  max_consecutive = NULL)

Arguments

x

metric. A vector

year

the year in which the metric was observed. A vector of the same length as x

period

the reference period of the anomaly. A vector of length 2 or NULL. If a vector, the first element indicates the beginning of the reference period and the second the end of the reference period. If NULL (the default) the reference period goes from the first to the last year.

max_missing

Numeric. Maximum number or proportion of missing values in x. If any number of missing values is allowed set to 1 (100%) or NULL.

max_consecutive

Numeric. Maximum number or proportion of consecutive missing values in x. If any number of missing values is allowed set to 1 (100%) or NULL.

Value

a vector with the anomaly of x

Examples


temperature_frame <- tibble::tibble(temperature = runif(100, 10, 20),
                                    year = 1901:2000)
reference_period <- c(1961, 1990)
temperature_frame %>%
dplyr::mutate(anomaly = calc_annual_anomaly(temperature,
                                           year,
                                           reference_period))

StatisticsNZ/er.helpers documentation built on Oct. 2, 2023, 7:24 a.m.