Skip to content

Please raise error or warning in epidata() on some 0-row output cases #356

Description

@brookslogan
library(epidatr)
#> ! epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not
#>   intended).
#> ℹ The cache directory is /home/fullname/.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
#>   /home/<username>/.cache/R/epidatr/logfile.txt.
# querying a non-existent geo_type simply yields 0 rows with no warning:
smoothed_pct_ed_visits_covid_not <- epidata("nssp", "smoothed_pct_ed_visits_covid", "hsa")
nrow(smoothed_pct_ed_visits_covid_not)
#> [1] 0
# vs. querying an actually-supported geo_type:
smoothed_pct_ed_visits_covid_hsa <- epidata("nssp", "smoothed_pct_ed_visits_covid", "hsa_nci")
nrow(smoothed_pct_ed_visits_covid_hsa)
#> [1] 139185

Created on 2026-08-14 with reprex v2.1.1

It'd be nice if the first query could raise an error and list the correctly-"spelled", applicable geo types for the source.

However, some geo types are not comprehensively supported. For example, some HSAs don't have NSSP data in CA (e.g., Alameda Contra Costa, which I believe should be 766). That's not just a simple check against epidata_meta("nssp")$nssp$geo_types. And one could get into the same situation when specifying time ranges as well. I think we discussed what to do in these cases in v4, and it seems that we ended up keeping a warning when returning 0 rows? That should be easy enough, though not as helpful as the much-more-complicated explanations of CA NSSP availability or outages /inactive systems.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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