
Pivot scores into a forecast unit by comparator matrix
Source:R/pairwise-comparisons.R
pivot_scores.RdPivots a set of scores into a matrix with one row per forecast unit
(excluding the compare column) and one column per comparator. Entries
are the values of metric and are NA where a comparator did not
provide a forecast for a given forecast unit.
The function is used by pairwise_comparison_one_group() to align the
scores of all comparators once, rather than once per pair of comparators.
Exact duplicate rows are dropped silently; rows that share a forecast
unit and comparator but are not otherwise identical raise an error, as
the scores could then not be pivoted unambiguously.
Arguments
- scores
An object of class
scores(a data.table with scores and an additional attributemetricsas produced byscore()).- compare
Character vector with a single colum name that defines the elements for the pairwise comparison. For example, if this is set to "model" (the default), then elements of the "model" column will be compared.
- metric
A string with the name of the metric to pivot. Unlike in
get_pairwise_comparisons(), there is no default: the caller must supply a single metric present inscores.