Closed brookslogan closed 1 year ago
Using devtools to load the latest epidatr and running
pkgload::dev_example("covid_hosp_facility")
yielded ""
.
Some earlier test code which might have failed due to the requested data not actually existing:
library(epidatr)
library(dplyr)
lookup = covid_hosp_facility_lookup(state="fl") %>% fetch_tbl()
lookup$hospital_pk # addresses in here, some maybe duplicates??
# having trouble figuring out how to get this to emit data!
facility_data = covid_hosp_facility(
lookup$hospital_pk[[1L]],
epirange(20221101, 20221114)
) %>% fetch_tbl()
adapt_online_example = covid_hosp_facility('390119', epirange(20201201, 20201207)) %>% fetch_tbl()
try_docs_example = covid_hosp_facility(hospital_pks = "100075", collection_weeks = epirange(202001, 202005)) %>% fetch_tbl()
This example with the old client worked:
res = Epidata$covid_hosp_facility('390119', Epidata$range(20201201, 20201207))
tbl =
raw$epidata %>%
data.table::rbindlist() %>%
tibble::as_tibble()
tbl %>%
summarize(min(collection_week), max(collection_week))
#> # A tibble: 1 × 2
#> `min(collection_week)` `max(collection_week)`
#> <int> <int>
#> 1 20221007 20221028
I have not yet tried applying this back to the new client. I'm surprised by the max collection week returned; will check on this. [The max collection "week" here does make sense given the alignment of the date representing the collection week + reporting delays/cadence + mirroring delays.]
This seems patched by now:
library(epidatr)
library(dplyr)
lookup = covid_hosp_facility_lookup(state="fl") %>% fetch_tbl()
lookup$hospital_pk
# This emits data
facility_data = covid_hosp_facility(
lookup$hospital_pk[[1L]],
epirange(20221101, 20221114)
) %>% fetch_tbl()
# This also emits data
covid_hosp_facility('390119', epirange(20201201, 20201207)) %>% fetch_tbl()
# This has a typo in the above post - the epirange values need to be dates
covid_hosp_facility(hospital_pks = "100075", collection_weeks = epirange(20200101, 20200501)) %>% fetch_tbl()
I am having trouble constructing a call that doesn't give an empty string as a result. We should fix this example / the implementation, and also move examples to use
fetch_tbl
instead offetch_csv
so this situation will raise an error (plus, as mentioned independently, to be more relevant to users).