tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

as_mable() "key" arg only works with character vectors #155

Closed markfairbanks closed 4 years ago

markfairbanks commented 4 years ago

as_mable() doesn't use tidyselect for the "key" arg, causing an error like the one seen below. I found this error originally when I tried to create a mable after using bind_rows() on a list of mables.

I could be wrong, but I was guessing that requiring character vectors wasn't intended behavior.

library(fpp3)
#> ── Attaching packages fpp3 0.1 ──
#> ✓ tibble      2.1.3     ✓ tsibble     0.8.6
#> ✓ dplyr       0.8.4     ✓ tsibbledata 0.1.0
#> ✓ tidyr       1.0.2     ✓ feasts      0.1.2
#> ✓ lubridate   1.7.4     ✓ fable       0.1.2
#> ✓ ggplot2     3.2.1

aus_ts <- tsibbledata::aus_retail %>%
  filter(year(Month) >= 2010) %>%
  group_by_key() %>%
  filter(group_indices() <= 2) %>%
  ungroup()

aus_mbl <- aus_ts %>%
  model(ets = ETS(Turnover))

as_tibble(aus_mbl) %>%
  as_mable(key = c(State, Industry), model = ets)
#> Error in is.data.frame(key): object 'State' not found

Created on 2020-02-17 by the reprex package (v0.3.0)

mitchelloharawild commented 4 years ago

This is unintended and will be fixed for the next release.

mitchelloharawild commented 4 years ago

Thanks! Should work as expected now.