Skip to contents

This is a helper function which adds the maximum (in the sense of latest observed) number of reported cases for each reference_date and computes the proportion of already reported cases for each combination of reference_date and report_date.


enw_add_max_reported(obs, copy = TRUE)



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).


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


A data.table with new columns max_confirm and cum_prop_reported. max_confirm is the maximum number of cases reported for a certain reference_date. cum_prop_reported is the proportion of cases for a certain reference_date that are reported until a given report_day, relative to all cases so far observed for this reference_date.


obs <- data.frame(report_date = as.Date("2021-01-01") + 0:2)
obs$reference_date <- as.Date("2021-01-01")
obs$confirm <- 1:3
#>    reference_date report_date .group max_confirm confirm cum_prop_reported
#>            <IDat>      <IDat>  <num>       <int>   <int>             <num>
#> 1:     2021-01-01  2021-01-01      1           3       1         0.3333333
#> 2:     2021-01-01  2021-01-02      1           3       2         0.6666667
#> 3:     2021-01-01  2021-01-03      1           3       3         1.0000000