Imputes NA values in the 'confirm' column. NA values are replaced with the last available observation or 0.
Arguments
- obs
A
data.frame
with at least 'confirm' and 'reference_date' columns.- by
A character vector of column names to group by. Defaults to an empty vector.
- copy
A logical; if
TRUE
(the default) creates a copy; otherwise, modifiesobs
in place.
See also
Preprocessing functions
enw_add_delay()
,
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_latest_data()
,
enw_metadata_delay()
,
enw_metadata()
,
enw_missing_reference()
,
enw_preprocess_data()
,
enw_reporting_triangle_to_long()
,
enw_reporting_triangle()
Examples
dt <- data.frame(
id = 1:3, confirm = c(NA, 1, 2),
reference_date = as.Date("2021-01-01")
)
enw_impute_na_observations(dt)
#> Key: <reference_date>
#> id confirm reference_date
#> <int> <num> <Date>
#> 1: 1 0 2021-01-01
#> 2: 2 1 2021-01-01
#> 3: 3 2 2021-01-01