View source: R/data-converters.R
enw_linelist_to_incidence | R Documentation |
This function takes a line list (i.e. tabular data where each
row represents a case) and aggregates to a count (new_confirm
) of cases by
user-specified reference_date
s and report_date
s. This is enables the use
of enw_preprocess_data()
and other epinowcast()
preprocessing functions.
enw_linelist_to_incidence(
linelist,
reference_date = "reference_date",
report_date = "report_date",
by = NULL,
max_delay,
completion_beyond_max_report = FALSE,
copy = TRUE
)
linelist |
An object coercible to a |
reference_date |
A date or a variable that can be coerced to a date
that represents the date of interest for the case. For example, if the
|
report_date |
A date or a variable that can be coerced to a date that represents the date the case was reported. The default is "report_date". |
by |
A character vector of variables to also aggregate by (i.e. as well
as using the |
max_delay |
The maximum number of days between the |
completion_beyond_max_report |
Logical, should entries be completed beyond the maximum date found in the data? Default: FALSE |
copy |
Should |
A data.table
with the following variables: reference_date
,
report_date
, new_confirm
, confirm
, delay
, and
any variables specified in by
.
Data converters
enw_add_cumulative()
,
enw_add_incidence()
,
enw_aggregate_cumulative()
,
enw_cumulative_to_incidence()
,
enw_incidence_to_cumulative()
,
enw_incidence_to_linelist()
linelist <- data.frame(
onset_date = as.Date(c("2021-01-02", "2021-01-03", "2021-01-02")),
report_date = as.Date(c("2021-01-03", "2021-01-05", "2021-01-04"))
)
enw_linelist_to_incidence(linelist, reference_date = "onset_date")
# Specify a custom maximum delay and allow completion beyond the maximum
# observed delay
enw_linelist_to_incidence(
linelist, reference_date = "onset_date", max_delay = 5,
completion_beyond_max_report = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.