Introduction

dhomer allows users to calculate proximity and accessibility to various data points from a geographic address input in order to essentially compute adjacency to determinants of health. Many determinants of health are integrated into the Census Bureau American Community Survey population estimates collected every 1 and 5 years, respectively.

The tidycensus package functions allows us to call and integrate ACS data into the dhomer functions for more comprehensive determinants of health computation.

vignette("other-langs", package = "tidycensus")
vignette("other-langs", package = "dplyr")
library(sf)
library(tidycensus)
library(dplyr)
library(leaflet)
library(dhomer)
data(libraries)

census_api_key(Sys.getenv("CENSUS_API_KEY"), install = FALSE, overwrite = FALSE)

Census Data Variables

Three variables of related to determinants of health:

Fetching Census Data

Estimates from the American Community Survey for below poverty, less than high school graduates and householder living alone are obtained and then divided by the population for the area since the data will be displayed on a map.

a_df <- suppressMessages(
  get_acs(
    variables = c(
      "below_poverty" = "B17021_002",
      "less_than_highschool" = "B06009_002",
      "nonfamily_households" = "B11001_008"
    ),
    state = "SC",
    geography = "county",
    geometry = TRUE,
    cache_table = TRUE,
    year = 2019,
    summary_var = "B01003_001",
    output = "wide"
  )
)

a_df <- a_df %>% 
  mutate(percent_below_pov = below_povertyE/summary_est)

Libraries

The counties show the percent population. Libraries are shown in blue.

qpal <- colorQuantile("RdYlBu", a_df$percent_below_pov, n = 5)

leaflet(data = a_df, width = "100%") %>% 
  addPolygons(data = a_df, stroke = FALSE, fillOpacity = 0.6, color = ~qpal(percent_below_pov)) %>% 
  addPolylines(weight = 2, color="gray") %>% 
  addCircles(data = libraries, 
             label = libraries$libname, 
             color = "blue") %>% 
  addLegend(title = "Percent Below Poverty",
            opacity = 1,
            pal = qpal, 
            values = ~a_df$percent_below_pov
) 


tamilyn/dhomer documentation built on Dec. 23, 2021, 7:44 a.m.