enw_add_delay: Add a delay variable to the observations

enw_add_delayR Documentation

Add a delay variable to the observations

Description

This helper function takes a data.frame or data.table of observations and adds the delay (numeric, in days) between reference_date and report_date for each observation.

Usage

enw_add_delay(obs, timestep = "day", copy = TRUE)

Arguments

obs

A data.frame containing at least the following variables: ⁠reference date⁠ (index date of interest), report_date (report date for observations), and confirm (cumulative observations by reference and report date).

timestep

The timestep to used. This can be a string ("day", "week", "month") or a numeric whole number representing the number of days.

copy

Should obs be copied (default) or modified in place?

Value

A data.table of observations with a new column delay.

See Also

Preprocessing functions enw_add_max_reported(), enw_add_metaobs_features(), enw_assign_group(), enw_complete_dates(), enw_construct_data(), enw_extend_date(), enw_filter_delay(), enw_filter_reference_dates(), enw_filter_report_dates(), enw_flag_observed_observations(), enw_impute_na_observations(), enw_latest_data(), enw_metadata(), enw_metadata_delay(), enw_missing_reference(), enw_preprocess_data(), enw_reporting_triangle(), enw_reporting_triangle_to_long()

Examples

obs <- data.frame(report_date = as.Date("2021-01-01") + -2:0)
obs$reference_date <- as.Date("2021-01-01")
enw_add_delay(obs)

seabbs/epinowcast documentation built on July 22, 2024, 8:54 p.m.