Convert a tidy table of quantiles into a ggdist
-format table of quantile intervals.
Source: R/tidy_quantiles_to_median_qi.R
quantile_table_to_median_qi.Rd
Expects a tidy quantile table (e.g. a hubverse quantile table or the
output of scoringutils::as_forecast_quantile()
.
Treats any columns in that table other than those specifying the
quantile level and the associated value as grouping variables,
and returns them in the output table.
Usage
quantile_table_to_median_qi(
quantile_table,
value_col,
quantile_level_col,
.width = NULL,
require_all_medians = TRUE,
require_all_widths = TRUE,
quantile_tol = 10
)
Arguments
- quantile_table
Tidy table of quantiles, as an object coerceible to a
tibble
. Must have columns representing the quantile level and the associated value- value_col
Column in the table specifying values.
- quantile_level_col
Column in the table specifying quantile levels
- .width
Vector of interval width(s) to for which to create rows in the output. If
NULL
(the default), use all and only the widths that can be computed from quantiles available inquantile_table
, as determined byget_available_qi_widths()
.- require_all_medians
Boolean. Error if the output is missing any medians? If
TRUE
, the function will succeed only if it can find a median (0.5
quantile) value for all groups present in the input and otherwise will error. DefaultTRUE
.- require_all_widths
Boolean. Error if the output is missing any of the requested
.width
s for any group? IfTRUE
, the function will succeed only if it can calculate all the requested interval.width
s for all the groups present in the input and otherwise will error. DefaultTRUE
.- quantile_tol
Round values in the
quantile_level_col
to this many decimal places, to avoid problems with floating point number equality comparisons. Passed as thedigits
argument tobase::round()
. Default 10.
Value
A tibble
in the output format of
ggdist::median_qi()