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.
Arguments
- obs
A
data.frame
containing at least the following variables:reference date
(index date of interest),report_date
(report date for observations), andconfirm
(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?
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)
#> report_date reference_date delay
#> <IDat> <IDat> <num>
#> 1: 2020-12-30 2021-01-01 -2
#> 2: 2020-12-31 2021-01-01 -1
#> 3: 2021-01-01 2021-01-01 0