Skip to content

When epi_recipe() outputs a regular recipe, errors can be confusing #168

New issue

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

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

Already on GitHub? Sign in to your account

Open
brookslogan opened this issue Apr 26, 2023 · 1 comment
Open

Comments

@brookslogan
Copy link
Contributor

brookslogan commented Apr 26, 2023

If epi_recipe() is provided data that's not an epi_df, it will output a regular recipe rather than an epi_recipe, causing some step functions to output somewhat confusing messages.

Artificial example:

library(epipredict)
#> Loading required package: epiprocess
#> 
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> Loading required package: parsnip
library(tibble)
epi_recipe(as_tibble(case_death_rate_subset)) %>%
  step_epi_ahead(death_rate, ahead = 7) %>%
  step_epi_lag(death_rate, lag = c(0,7,14))
#> Error in `step_epi_ahead()`:
#> ! This recipe step can only operate on an `epi_recipe`.

Created on 2023-04-26 by the reprex package (v2.0.1)

More realistically, @dshemetov and I ran into this when feeding in a covidcast_signal before it had been converted to epi_df format.

A couple quick ideas on potential resolutions:

  • Add S3 methods to the steps for regular recipes, just to give better error messages.
  • Always output an epi_recipe from epi_recipe(), but complain in step functions if the appropriate roles have not been set. This might require fixing some hard-coded references to geo_value and/or time_value columns (rather than selecting based on roles) in some steps.
@dajmcdon
Copy link
Contributor

I would lean toward the second option. This potentially interacts with #175 .

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

No branches or pull requests

2 participants