cmu-delphi / cmu-delphi/epipredict

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

Open
#168 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
18
Forks
13
Avg merge
21d 58m
Merged PRs (30d)
1

Description

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:

``` r
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](https://reprex.tidyverse.org) (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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.