minor fix to hospitalizations() internals
@hrbrmstr thank you for developing and maintaining this package!
i have been using the hospitalizations() function to retrieve FluSurv-NET data. it looks like a recent update may have had a minor bug in this function. the problem was discussed in an issue thread (https://github.com/hrbrmstr/cdcfluview/issues/30#issuecomment-1329912762) ... i am putting together this PR to implement the suggestion from @IMcGovern-Seqirus
the code below should demonstrate the issue with the code currently on main branch => the fix as implemented on my fork (and incoming via this PR).
thanks again for creating this package. i am happy to make any adjustments to the PR as you see fit.
remotes::install_github("hrbrmstr/cdcfluview")
.rs.restartR()
packageVersion("cdcfluview")
#> [1] '1.0.0.9000'
library(cdcfluview)
all_hosp <- hospitalizations()
#> Error in hospitalizations(): object 'res' not found
remotes::install_github("vpnagraj/cdcfluview")
.rs.restartR()
packageVersion("cdcfluview")
#> [1] '1.0.0.9001'
library(cdcfluview)
all_hosp <- hospitalizations()
max(all_hosp$weekend)
#> [1] "2023-04-29"
and devtools::check() on local machine comes back clean with 0 ERRORs, 0 WARNINGs, 0 NOTEs
This is great - is there any way to have this function retrieve the weekly hospitalization data that is published on the weekly report? Currently it is only updating through April, 2023.
I haven't tested this thoroughly, but it appears that hospitalizations:
- only downloads FluSurv-NET data (not the individual component networks: EIP & IHSP)
all.equal(hospitalizations(surveillance_area = 'flusurv', region = 'all')$rates, hospitalizations(surveillance_area = 'eip', region = 'all')$rates) - duplicates the data 3x (once for each of "FluSurv-NET, EIP, IHSP) because of joining by
"catchmentid"instead ofc("networkid", "catchmentid")(link) - drops the columns containing race and sex info, which results in multiple measurements for each category.
This might be a working fix for downloading only the FluSurv-NET data: https://github.com/philipshirk/cdcfluview/blob/master/R/hospital.r