cdcfluview icon indicating copy to clipboard operation
cdcfluview copied to clipboard

minor fix to hospitalizations() internals

Open vpnagraj opened this issue 2 years ago • 2 comments

@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

vpnagraj avatar May 27 '23 13:05 vpnagraj

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.

dwchal avatar Sep 11 '23 15:09 dwchal

I haven't tested this thoroughly, but it appears that hospitalizations:

  1. 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)
  2. duplicates the data 3x (once for each of "FluSurv-NET, EIP, IHSP) because of joining by "catchmentid" instead of c("networkid", "catchmentid") (link)
  3. 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

philipshirk avatar Nov 06 '23 17:11 philipshirk