Skip to content

Date parsing for NCHS mortality causes issues fetching data #257

@nmdefries

Description

@nmdefries

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions