Libraries
library(tidycensus)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.7
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 2.1.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(crsuggest)
## Using the EPSG Dataset v10.019, a product of the International Association of Oil & Gas Producers.
## Please view the terms of use at https://epsg.org/terms-of-use.html.
Load Census API Key (Hidden)
## To install your API key for use in future sessions, run this function with `install = TRUE`.
ACS Variables
v19 <- load_variables(2019, "acs5", cache = TRUE)
#View(v19)
v19 %>% filter(grepl('veteran', label, ignore.case = TRUE))
PA Data
options(tigris_use_cache = TRUE)
centre_acs_map_data <- get_acs(state = "PA", county = "Centre", geography = "tract", variables = "B21001_002", geometry = TRUE)
## Getting data from the 2015-2019 5-year ACS
#pa_acs_B21001_002_map_data <- get_acs(state = "PA", geography = "county", variables = "B21001_002", geometry = TRUE)
pa_acs_map_data <- c()
acs_variables_of_interest <- c("B21001_002", "B21002_002", "B21002_016", "B21005_007", "B21005_025", "B21100_003", "B21002_012",
"B21002_011", "B21002_007", "B21002_008")
# default survey = acs5 ("acs1", "acs3", and "acs5") meaning 2015-2019 5-year estimates
for (acsvar in acs_variables_of_interest) {
pa_acs_map_data[[acsvar]] <- get_acs(state = "PA", geography = "county", variables = acsvar, geometry = TRUE)
}
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS
## Getting data from the 2015-2019 5-year ACS