tidyverts / fabletools

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

[.mbl_df #335

Closed romainfrancois closed 2 years ago

romainfrancois commented 2 years ago

Originally in https://github.com/tidyverse/dplyr/issues/6081

library(fabletools)
library(fable)

lung_deaths_agg <- as_tsibble(cbind(mdeaths, fdeaths)) %>%
  aggregate_key(key, value = sum(value))

df_mable <- lung_deaths_agg %>%
  model(lm = TSLM(value ~ trend() + season()))

# A mable
df_mable
#> # A mable: 3 x 2
#> # Key:     key [3]
#>   key               lm
#>   <chr*>       <model>
#> 1 fdeaths       <TSLM>
#> 2 mdeaths       <TSLM>
#> 3 <aggregated>  <TSLM>

# Not a mable?
df_mable[c("key", "lm")]
#> # A tibble: 3 × 2
#>   key               lm
#>   <chr*>       <model>
#> 1 fdeaths       <TSLM>
#> 2 mdeaths       <TSLM>
#> 3 <aggregated>  <TSLM>
mitchelloharawild commented 2 years ago

Fixed, thanks for the bug report.