tidymodels / broom

Convert statistical analysis objects from R into tidy format
https://broom.tidymodels.org
Other
1.43k stars 302 forks source link

augment() fails #1192

Closed USMortality closed 4 months ago

USMortality commented 4 months ago

The problem

augment() fails. Not sure why, this is a pretty simple example...

Reproducible example

library(fable)
library(tsibble)
library(dplyr)

x <- 2015:2021
y <- c(878.6, 866.4, 864.9, 1017.8, 1029.5, 961.5, 896.2)

df_bl <- tibble(x = x, y = y) |> as_tsibble(index = x)
# Split data into training and test
df_train <- df_bl |> filter(x <= 2019)
df_test <- df_bl |> filter(x > 2019)

df_train |>
  as_tsibble(index = x) |>
  model(TSLM(y ~ trend())) |>
  broom::augment()
Error in `mutate()`:
ℹ In argument: `dplyr::across(...)`.
Caused by error in `across()`:
! Can't compute column `TSLM(y ~ trend())`.
Caused by error in `mutate()`:
ℹ In argument: `.fitted = fitted(x, ...)[[".fitted"]]`.
Caused by error in `object$fitted`:
! $ operator is invalid for atomic vectors
Run `rlang::last_trace()` to see where the error occurred.
simonpcouch commented 4 months ago

Thanks for the issue!

The object you've passed to augment() is a mbl_df. The fabletools package defines the augment() method for mbl_dfs; please file an issue there to have this troubleshooted.

simonpcouch commented 4 months ago

Ah, looks like you did file an issue there. Duplicate of https://github.com/tidyverts/fabletools/issues/399.

github-actions[bot] commented 3 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.