Join hubverse forecasts to observed data
Source:R/hubverse_to_scorable.R
hubverse_table_with_obs.RdExpects forecast output in hubverse format (e.g. as created by
get_hubverse_quantile_table()) and an observed data table with location,
date, and value columns. The names of these columns the observed
data table can be configured; defaults are "location", "date",
and "value", respectively (direct correspondence with
standard Hub "target data" tables).
Usage
hubverse_table_with_obs(
hubverse_forecast_table,
observation_table,
obs_value_column = "value",
obs_date_column = "date",
obs_value_name = "observed",
id_cols = c("location", "target"),
join = "full"
)Arguments
- hubverse_forecast_table
Forecasts, as a hubverse-format
tibble, for instance as produced byget_hubverse_quantile_table(), with columns includingtarget_end_date, andlocation.- observation_table
observations, as a
tibble.- obs_value_column
Name of the column containing observed values in the
observedtable, as a string. Default"value"- obs_date_column
Name of the column containing date values in the
observedtable, as a string. Will be joined to thetarget_end_datecolumn in the hubverse table. Default"date"- obs_value_name
Name for the column of observed values in the resulting table (since
"value"clashes with the forecast value column in a standard hubverse table. Default"observed".- id_cols
Additional ID columns to join on, in addition to
obs_date_column. Defaultc("location", "target").- join
Which SQL-style
dplyrmutating join function to use when joining the tables. Options are"full"(fordplyr::full_join()),"left"(dplyr::left_join()),"right"(dplyr::right_join()), and"inner"(dplyr::inner_join()). In the join, the hubverse forecast table is the left table (x) and the observation table is the right table (y). Default"full"(i.e. keep all forecasts and observations, even if some forecasts do not have a corresponding observation or some observations do not have a corresponding forecast).
Value
A tibble with the observed values
added.