Skip to content

covid_hosp_facility example yields empty string #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brookslogan opened this issue Nov 14, 2022 · 2 comments · Fixed by #89
Closed

covid_hosp_facility example yields empty string #62

brookslogan opened this issue Nov 14, 2022 · 2 comments · Fixed by #89
Assignees
Labels
bug Something isn't working P0 Top priority

Comments

@brookslogan
Copy link
Contributor

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 of fetch_csv so this situation will raise an error (plus, as mentioned independently, to be more relevant to users).

@brookslogan brookslogan added bug Something isn't working P0 Top priority labels Nov 14, 2022
@brookslogan
Copy link
Contributor Author

brookslogan commented Nov 14, 2022

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.]

@dshemetov
Copy link
Contributor

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Top priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants