Skip to contents

See hubUtils::model_id_merge() for details.

Value

tbl with either team_abbr and model_abbr merged into a single model_id column or model_id split into columns team_abbr and model_abbr.

a tibble with model_id column split into separate team_abbr and model_abbr columns

Examples

if (requireNamespace("hubData", quietly = TRUE)) {
  hub_con <- hubData::connect_hub(system.file("testhubs/flusight", package = "hubUtils"))
  tbl <- hub_con %>%
    dplyr::filter(output_type == "quantile", location == "US") %>%
    dplyr::collect() %>%
    dplyr::filter(forecast_date == max(forecast_date))

  tbl_split <- model_id_split(tbl)
  tbl_split

  # Merge model_id
  tbl_merged <- model_id_merge(tbl_split)
  tbl_merged

  # Split / Merge using custom separator
  tbl_sep <- tbl
  tbl_sep$model_id <- gsub("-", "_", tbl_sep$model_id)
  tbl_sep <- model_id_split(tbl_sep, sep = "_")
  tbl_sep
  tbl_sep <- model_id_merge(tbl_sep, sep = "_")
  tbl_sep
}
#> # A tibble: 92 × 8
#>    model_id     forecast_date horizon target location output_type output_type_id
#>    <chr>        <date>          <int> <chr>  <chr>    <chr>       <chr>         
#>  1 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.01          
#>  2 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.025         
#>  3 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.05          
#>  4 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.1           
#>  5 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.15          
#>  6 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.2           
#>  7 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.25          
#>  8 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.3           
#>  9 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.35          
#> 10 hub_baseline 2023-05-08          1 wk ah… US       quantile    0.4           
#> # ℹ 82 more rows
#> # ℹ 1 more variable: value <dbl>