Skip to contents

This function takes a data.table of aggregate counts or something coercible to a data.table (such as a data.frame) and converts it to a line list where each row represents a case.

Usage

enw_incidence_to_linelist(
  obs,
  reference_date = "reference_date",
  report_date = "report_date"
)

Arguments

obs

An object coercible to a data.table (such as a data.frame) which must have a new_confirm column.

reference_date

A character string of the variable name to use for the reference_date in the line list. The default is "reference_date".

report_date

A character string of the variable name to use for the report_date in the line list. The default is "report_date".

Value

A data.table with the following variables: id, reference_date, report_date, and any other variables in the obs object. Rows in obs

will be duplicated based on the new_confirm column. reference_date and report_date may be renamed if reference_date and report_date are supplied.

Examples

incidence <- enw_add_incidence(germany_covid19_hosp)
incidence <- enw_filter_reference_dates(
  incidence[location == "DE"], include_days = 10
)
enw_incidence_to_linelist(incidence, reference_date = "onset_date")
#>           id onset_date location age_group report_date delay
#>        <int>     <IDat>   <fctr>    <fctr>      <IDat> <int>
#>     1:     1 2021-10-10       DE       00+  2021-10-10     0
#>     2:     2 2021-10-10       DE       00+  2021-10-10     0
#>     3:     3 2021-10-10       DE       00+  2021-10-10     0
#>     4:     4 2021-10-10       DE       00+  2021-10-10     0
#>     5:     5 2021-10-10       DE       00+  2021-10-10     0
#>    ---                                                      
#> 18753: 18753 2021-10-20       DE       80+  2021-10-20     6
#> 18754: 18754 2021-10-20       DE       80+  2021-10-20     6
#> 18755: 18755 2021-10-20       DE       80+  2021-10-20     6
#> 18756: 18756 2021-10-20       DE       80+  2021-10-20     6
#> 18757: 18757 2021-10-20       DE       80+  2021-10-20     6