Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

The output of clean_anomalies() is a time tibble, which doesn't play nice with timetk::future_frame() #69

Open
mabuimo opened this issue Oct 11, 2023 · 0 comments

Comments

@mabuimo
Copy link

mabuimo commented Oct 11, 2023

Hi,
Let's clean the anomalies of a given dataset:

data(tidyverse_cran_downloads)

cleaned <- tidyverse_cran_downloads |>
  anomalize::time_decompose(count, method = "stl") |>
  anomalize::anomalize(remainder, method = "iqr") |>
  anomalize::clean_anomalies()

The output is a time tibble. Now if you extend these time series by 12 points:

cleaned |> 
  dplyr::group_by(package) |>
  timetk::future_frame(
    .date_var = date ,
    .length_out = 12,
    .bind_data = FALSE
  ) |>
  dplyr::ungroup()

You get:

Error in `tbl_at_vars()`:
! Can't subset columns that don't exist.
✖ Column `package` doesn't exist.

This error can be solved by ensuring that cleaned is a tibble before extending the dataframe:

cleaned |> 
as_tibble() |> 
  dplyr::group_by(package) |>
  timetk::future_frame(
    .date_var = date ,
    .length_out = 12,
    .bind_data = FALSE
  ) |>
  dplyr::ungroup()

Thank you Matt!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant