Skip to content
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

Requestion version with no data in grouped epix_slide() produces confusing error message #630

Open
brookslogan opened this issue Mar 12, 2025 · 0 comments

Comments

@brookslogan
Copy link
Contributor

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(epiprocess)
#> Loading required package: epidatasets
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
#> 
#> Attaching package: 'epiprocess'
#> The following object is masked from 'package:stats':
#> 
#>     filter
case_death_rate_archive %>%
  group_by(geo_value) %>%
  epix_slide(
    .versions = min(.$private$ungrouped$DT$version),
    max_time_value = max(time_value)
  )
#> # A tibble: 56 × 3
#> # Groups:   geo_value [56]
#>    geo_value version    max_time_value
#>  * <chr>     <date>     <date>        
#>  1 ak        2020-09-01 2020-08-31    
#>  2 al        2020-09-01 2020-08-31    
#>  3 ar        2020-09-01 2020-08-31    
#>  4 as        2020-09-01 2020-08-31    
#>  5 az        2020-09-01 2020-08-31    
#>  6 ca        2020-09-01 2020-08-31    
#>  7 co        2020-09-01 2020-08-31    
#>  8 ct        2020-09-01 2020-08-31    
#>  9 dc        2020-09-01 2020-08-31    
#> 10 de        2020-09-01 2020-08-31    
#> # ℹ 46 more rows
case_death_rate_archive %>%
  group_by(geo_value) %>%
  epix_slide(
    .versions = min(.$private$ungrouped$DT$version) - 1L,
    max_time_value = max(time_value)
  ) %>%
  ungroup()
#> Warning in max.default(structure(numeric(0), class = "Date"), na.rm = FALSE):
#> no non-missing arguments to max; returning -Inf
#> Error in `group_by()`:
#> ! Must group by variables found in `.data`.
#> ✖ Column `geo_value` is not found.
case_death_rate_archive %>%
  epix_slide(
    .versions = min(.$DT$version) - 1L,
    max_time_value = max(time_value)
  )
#> Warning in max.default(structure(numeric(0), class = "Date"), na.rm = FALSE):
#> no non-missing arguments to max; returning -Inf
#> # A tibble: 1 × 2
#>   version    max_time_value
#> * <date>     <date>        
#> 1 2020-08-31 -Inf

Created on 2025-03-12 with reprex v2.1.1

  • First case is grouped, requesting a version containing data.
  • Second case is grouped, requesting a version not containing any data. ---> confusing error message
  • Third case is ungrouped, requesting a version not containing any data. ---> perhaps still confusing, but a little better.

This situation may arise when misremembering the bounds of an archive and requesting a version manually, or from issues copy-pasting code dealing with a different archive, or looping code over multiple archives with differing version ranges.

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

1 participant