R/kff_icu_beds.R

Defines functions kff_icu_beds

Documented in kff_icu_beds

#' Kaiser Family Foundation US County-level ICU bed data
#'
#' @source
#' - \url{https://khn.org/news/as-coronavirus-spreads-widely-millions-of-older-americans-live-in-counties-with-no-icu-beds/}
#' - \url{https://khn.org/wp-content/uploads/sites/2/2020/03/KHN-ICU-bed-county-analysis_2.zip}
#' 
#' @importFrom readxl read_xlsx
#'
#' @family data-import
#' @family healthcare-systems
#' 
#' @return a data.frame
#'
#' @examples
#' res = kff_icu_beds()
#' colnames(res)
#' head(res)
#' dplyr::glimpse(res)
#' summary(res)
#' 
#' @export
kff_icu_beds <- function() {    
    tmpd = tempdir()
    url = 'https://khn.org/wp-content/uploads/sites/2/2020/03/KHN-ICU-bed-county-analysis_2.zip'
    rpath = s2p_cached_url(url)
    dat2 = utils::unzip(rpath, overwrite=TRUE, exdir=tmpd)
    dat3 = readxl::read_xlsx(dat2[1])
    colnames(dat3)[c(1,2)] = c('fips','county')
    dat3
}
seandavi/sars2pack documentation built on May 13, 2022, 3:41 p.m.