Join hubverse forecasts to observed data
Source:R/hubverse_to_scorable.R
hubverse_table_with_obs.Rd
Expects forecast output in hubverse format (e.g. as created by
get_hubverse_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_location_column = "location",
obs_date_column = "date",
obs_value_name = "observed",
join = "full"
)
Arguments
- hubverse_forecast_table
Forecasts, as a hubverse-format
tibble
, for instance as produced byget_hubverse_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
observed
table, as a string. Default"value"
- obs_location_column
Name of the column containing location values in the
observed
table, as a string. Default"location"
- obs_date_column
Name of the column containing date values in the
observed
table, as a string. 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"
.- join
Which SQL-style
dplyr
mutating 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.