This is a helper function which allows users to filter datasets
by reference date. This is useful, for example, when evaluating nowcast
performance against fully observed data. Users may wish to combine this
function with enw_filter_report_dates()
. Note that by definition it is
assumed that report dates must be equal or greater than the corresponding
reference date (i.e a report cannot happen before the event being reported
occurs). This means that this function will also filter out any report dates
that are earlier than their corresponding reference date.
Arguments
- obs
A
data.frame
; must havereport_date
andreference_date
columns.- earliest_date
earliest reference date to include in the data set
- include_days
if
earliest_date
is not given, the number of reference dates to include, ending with the latest reference date included (determined bylatest_date
orremove_days
).- latest_date
Date, the latest reference date to include in the returned dataset.
- remove_days
Integer, if
latest_date
is not given, the number of reference dates to remove, starting from the latest date included.
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_report_dates()
,
enw_flag_observed_observations()
,
enw_impute_na_observations()
,
enw_latest_data()
,
enw_metadata_delay()
,
enw_metadata()
,
enw_missing_reference()
,
enw_preprocess_data()
,
enw_reporting_triangle_to_long()
,
enw_reporting_triangle()
Examples
# Filter by date
enw_filter_reference_dates(
germany_covid19_hosp,
earliest_date = "2021-09-01",
latest_date = "2021-10-01"
)
#> reference_date location age_group confirm report_date
#> <IDat> <fctr> <fctr> <int> <IDat>
#> 1: 2021-09-01 DE 00+ 124 2021-09-01
#> 2: 2021-09-02 DE 00+ 94 2021-09-02
#> 3: 2021-09-03 DE 00+ 130 2021-09-03
#> 4: 2021-09-04 DE 00+ 82 2021-09-04
#> 5: 2021-09-05 DE 00+ 42 2021-09-05
#> ---
#> 129111: 2021-09-01 DE-TH 05-14 0 2021-10-20
#> 129112: 2021-09-01 DE-TH 15-34 0 2021-10-20
#> 129113: 2021-09-01 DE-TH 35-59 1 2021-10-20
#> 129114: 2021-09-01 DE-TH 60-79 2 2021-10-20
#> 129115: 2021-09-01 DE-TH 80+ 2 2021-10-20
#
# Filter by days
enw_filter_reference_dates(
germany_covid19_hosp,
include_days = 10, remove_days = 10
)
#> reference_date location age_group confirm report_date
#> <IDat> <fctr> <fctr> <int> <IDat>
#> 1: 2021-09-30 DE 00+ 110 2021-09-30
#> 2: 2021-10-01 DE 00+ 105 2021-10-01
#> 3: 2021-10-02 DE 00+ 97 2021-10-02
#> 4: 2021-10-03 DE 00+ 41 2021-10-03
#> 5: 2021-10-04 DE 00+ 23 2021-10-04
#> ---
#> 20940: 2021-09-30 DE-TH 05-14 1 2021-10-20
#> 20941: 2021-09-30 DE-TH 15-34 2 2021-10-20
#> 20942: 2021-09-30 DE-TH 35-59 6 2021-10-20
#> 20943: 2021-09-30 DE-TH 60-79 4 2021-10-20
#> 20944: 2021-09-30 DE-TH 80+ 10 2021-10-20