enw_add_metaobs_features | R Documentation |
If not already present, annotates time series data with metadata commonly used in models: day of week, and days, weeks, and months since start of time series.
enw_add_metaobs_features(
metaobs,
holidays = NULL,
holidays_to = "Sunday",
datecol = "date"
)
metaobs |
Raw data, coercible via |
holidays |
a (potentially empty) vector of dates (or input
coercible to such; see |
holidays_to |
A character string to assign to holidays, when |
datecol |
The column in |
Effects models often need to include covariates for time-based features, such as day of the week (e.g. to reflect different care-seeking and/or reporting behaviour).
This function is called from within enw_preprocess_data()
to systematically
annotate metaobs
with these commonly used metadata, if not already present.
However, it can also be used directly on other data.
A copy of the metaobs
input, with additional columns:
day_of_week
, a factor of values as output from weekdays()
and
possibly as holiday_to
if distinct from weekdays values
day
, numeric, 0 based from start of time series
week
, numeric, 0 based from start of time series
month
, numeric, 0 based from start of time series
Preprocessing functions
enw_add_delay()
,
enw_add_max_reported()
,
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_impute_na_observations()
,
enw_latest_data()
,
enw_metadata()
,
enw_metadata_delay()
,
enw_missing_reference()
,
enw_preprocess_data()
,
enw_reporting_triangle()
,
enw_reporting_triangle_to_long()
# make some example date
nat_germany_hosp <- subset(
germany_covid19_hosp,
location == "DE" & age_group == "80+"
)[1:40]
basemeta <- enw_add_metaobs_features(
nat_germany_hosp,
datecol = "report_date"
)
basemeta
# with holidays - n.b.: holidays not found are silently ignored
holidaymeta <- enw_add_metaobs_features(
nat_germany_hosp,
datecol = "report_date",
holidays = c(
"2021-04-04", "2021-04-05",
"2021-05-01", "2021-05-13",
"2021-05-24"
),
holidays_to = "Holiday"
)
holidaymeta
subset(holidaymeta, day_of_week == "Holiday")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.