
Add the maximum number of cases reported on a given day
Source:R/preprocess.R
enw_add_max_reported.Rd
Add the maximum number of cases reported on a given day to the data set. This is useful for calculating the proportion of cases reported on a given day which is also done in this function.
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).- copy
Should
obs
be copied (default) or modified in place?
Value
A data.table with a max_confirm
and cum_prop_reported
columns added. max_confirm
is the maximum number of cases reported
on a given day. cum_prop_reported
is the proportion of cases
reported on a given day relative to the maximum number of cases
reported on a given day.
See also
Preprocessing functions
enw_add_delay()
,
enw_add_metaobs_features()
,
enw_assign_group()
,
enw_complete_dates()
,
enw_construct_data()
,
enw_delay_filter()
,
enw_delay_metadata()
,
enw_extend_date()
,
enw_filter_reference_dates()
,
enw_filter_report_dates()
,
enw_latest_data()
,
enw_metadata()
,
enw_missing_reference()
,
enw_preprocess_data()
,
enw_reporting_triangle_to_long()
,
enw_reporting_triangle()
Examples
obs <- data.frame(report_date = as.Date("2021-01-01") + 0:2)
obs$reference_date <- as.Date("2021-01-01")
obs$confirm <- 1:3
enw_add_max_reported(obs)
#> reference_date .group max_confirm report_date confirm cum_prop_reported
#> 1: 2021-01-01 1 3 2021-01-01 1 0.3333333
#> 2: 2021-01-01 1 3 2021-01-02 2 0.6666667
#> 3: 2021-01-01 1 3 2021-01-03 3 1.0000000