cmu-delphi / epidatr

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

Date parsing for NCHS mortality causes issues fetching data #257

Closed nmdefries closed 6 months ago

nmdefries commented 6 months ago

From

pub_covidcast("nchs-mortality", "deaths_flu_incidence_prop", geo_type = "state", time_type = "week", geo_values="*", time_values = epirange(200006, 202508), fetch_args = fetch_args_list(dry_run = TRUE))

the call URL is: https://api.delphi.cmu.edu/epidata/covidcast/?data_source=nchs-mortality&signals=deaths_flu_incidence_prop&geo_type=state&time_type=week&geo_values=%2A&time_values=200006-202508, which successfully fetches data.

But running not as dry_run, the same call fails

pub_covidcast("nchs-mortality", "deaths_flu_incidence_prop", geo_type = "state", time_type = "week", geo_values="*", time_values = epirange(200006, 202508))
# Error in charToDate(x) : 
#   character string is not in a standard unambiguous format
# Timing stopped at: 0.17 0 0.734

A similar call where time_values are provided as dates rather than epiweeks succeeds, but doesn't return any data.

pub_covidcast("nchs-mortality", "deaths_flu_incidence_prop", geo_type = "state", time_type = "week", geo_values="*", time_values = epirange(20000601, 20250801))
# # A tibble: 0 × 0
# Warning message:
# epidata warning: `no results` 

The corresponding URL doesn't return any data.

So it seems that our input time_values are expected to be in "YYYYMMDD" format, but NCHS Mortality needs "YYYYWW" format to get data.