cmu-delphi / epidatr

Delphi Epidata API R Client
https://cmu-delphi.github.io/epidatr/
Other
1 stars 5 forks source link

Can't use `as_of = <Date>` with caching enabled #258

Closed brookslogan closed 6 months ago

brookslogan commented 6 months ago

Thanks to @XuedaShen for pointing this out.

library(epidatr)
#> ! epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not
#>   intended).
#> ℹ The cache directory is ~/.cache/R/epidatr.
#> ℹ The cache will be cleared after 14 days and will be pruned if it exceeds 4096
#>   MB.
#> ℹ The log of cache transactions is stored at ~/.cache/R/epidatr/logfile.txt.
pub_covidcast(
  source = "hhs",
  signals = "confirmed_admissions_covid_1d_prop_7dav",
  geo_type = "state",
  time_type = "day",
  geo_values = "*",
  time_values = epirange(20201101, 20231231),
  as_of = as.Date("2024-02-28")
)
#> Error in charToDate(x): character string is not in a standard unambiguous format

Created on 2024-02-28 with reprex v2.0.2

This is from cache_epidata_call()->check_is_recent(), probably similar to check_is_cachable() in #194.

brookslogan commented 6 months ago

>= is comparing a Date-class as_of to a %Y%m%d-formatted string, trying to convert the RHS to Date and having issues (a %Y-%m-%d string would work with the auto conversion, but not %Y%m%d. But %Y-%m-%d might have issues on other types of as_ofs).