R/cdc_social_vulnerability_index.R

Defines functions cdc_social_vulnerability_index

Documented in cdc_social_vulnerability_index

#' US CDC Social Vulnerability Index
#'
#' The CDC's Social Vulnerability Index (SVI), created and maintained
#' by the Geospatial Research, Analysis, and Services Program (GRASP),
#' uses US Census data to determine the social vulnerability of every
#' county and tract. This index ranks each county and tract based upon
#' 15 social factors including poverty, lack of vehicle access, and
#' crowded housing, and groups them into four related themes: 1)
#' Socioeconomic, 2) Housing Composition and Disability, 3) Minority
#' Status and Language, and 4) Housing and Transportation.
#'
#' @details
#'
#' Theme rankings: For each of the four themes, we summed the
#' percentiles for the variables comprising each theme. We ordered the
#' summed percentiles for each theme to determine theme-specific
#' percentile rankings. The four summary theme ranking variables,
#' detailed in the Data Dictionary below, are:
#' 
#' - Socioeconomic - RPL_THEME1
#' - Household Composition & Disability - RPL_THEME2
#' - Minority Status & Language - RPL_THEME3
#' - Housing Type & Transportation - RPL_THEME4
#'
#' Overall tract rankings: We summed the sums for each theme, ordered
#' the tracts, and then calculated overall percentile rankings. Please
#' note; taking the sum of the sums for each theme is the same as
#' summing individual variable rankings. The overall tract summary
#' ranking variable is RPL_THEM
#' 
#' For detailed documentation, see
#' \url{https://svi.cdc.gov/Documents/Data/2018_SVI_Data/SVI2018Documentation.pdf}
#' 
#' @source \url{https://svi.cdc.gov/}
#'
#' @author Sean Davis <seandavi@gmail.com>
#'
#' @family data-import
#' @family demographics
#'
#' @return a data.frame
#'
#' @examples
#'
#' res = cdc_social_vulnerability_index()
#' head(res)
#'
#' # limit to index columns only 
#' res %>% dplyr::select(
#'     state_fips:e_totpop,dplyr::starts_with('rpl_'))
#' 
#' 
#' @export
cdc_social_vulnerability_index <- function() {
    rpath = s2p_cached_url('https://opendata.arcgis.com/datasets/cbd68d9887574a10bc89ea4efe2b8087_1.csv')
    dat = readr::read_csv(rpath, col_types = readr::cols())
    colnames(dat) = tolower(colnames(dat))
    dat$state = stringr::str_to_title(dat$state)
    dat$st = integer_to_fips(as.integer(dat$st))
    dat = dplyr::rename(dat,state_fips='st')
    dat
}
seandavi/sars2pack documentation built on May 13, 2022, 3:41 p.m.