Add prediction traces to an existing ptt_plot.
ptt_plot_add_prediction_traces.Rd
Outputs a plotly object.
Usage
ptt_plot_add_prediction_traces(
p,
pred_data,
grouping = sarja_nmi,
n_obs = 2,
with_labs = T,
isolate_primary = F,
showlegend = F,
hovertext = list(rounding = 1, unit = "%", extra = "(ennuste)")
)
Arguments
- p
Plotly object created with ptt_plot to add prediction traces to.
- pred_data
Tibble in ptt prediction data format.
- grouping
Tibble column used for grouping in plot, should be labeled the same as data used for parent ptt_plot.
- n_obs
Number of observations (counted from the latest) used from the prediction set pred_data.
- isolate_primary
Separates the first factor in parent plot grouping by line width.
- showlegend, with_labs
Controls prediction trace legend. Hovertemplate takes labeling based on with_labs.
- hovertext
A list describing hovertext items "list(rounding = 1, unit = "%", extra = "(ennuste)")".
Examples
e <- readxl::read_excel("ptt_ennusteet_KT.xlsx") |> dplyr::filter(stringr::str_detect(sarja, "B1GMH|P3KS14"))
#> Error: `path` does not exist: 'ptt_ennusteet_KT.xlsx'
p <- p |> ptt_plot_add_prediction_traces(e)
#> Error in pivot_longer(pred_data, cols = matches("[0-9]{4}"), names_to = "year"): object 'e' not found
p
#> Error in eval(expr, envir, enclos): object 'p' not found