View source: R/forecast-unit.R
set_forecast_unit | R Documentation |
Helper function to set the unit of a single forecast (i.e. the
combination of columns that uniquely define a single forecast) manually.
This simple function keeps the columns specified in forecast_unit
(plus
additional protected columns, e.g. for observed values, predictions or
quantile levels) and removes duplicate rows. set_forecast_unit()
will
mainly be called when constructing a forecast
object
via the forecast_unit
argument in as_forecast_<type>
.
If not done explicitly, scoringutils
attempts to determine the unit
of a single forecast automatically by simply assuming that all column names
are relevant to determine the forecast unit. This may lead to unexpected
behaviour, so setting the forecast unit explicitly can help make the code
easier to debug and easier to read.
set_forecast_unit(data, forecast_unit)
data |
A data.frame (or similar) with predicted and observed values. See the details section of for additional information on the required input format. |
forecast_unit |
Character vector with the names of the columns that uniquely identify a single forecast. |
A data.table with only those columns kept that are relevant to scoring or denote the unit of a single forecast as specified by the user.
library(magrittr) # pipe operator
example_quantile %>%
scoringutils:::set_forecast_unit(
c("location", "target_end_date", "target_type", "horizon", "model")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.