For this part of the lab, I elected to examine the population of disabled veterans living in Virginia Beach, VA. To help narrow down which variable to examine from the ACS, I went to CensusReporter.org’s website and pulled up their Table Codes, which deciphered the codes available in the ACS.
As always, loading in the relevant packages.
# Load Packages ----
library(tidycensus)
library(mapview)
library(tidyverse)
library(tigris)
library(ggiraph)
library(RColorBrewer)
library(sf)
With the packages loaded, I loaded the variables from the ACS and
then used get_acs to pull the variable of interest,
B21100_001. From the CensusReporter.org decoder, “21”
is for veterans, “100” is for service connected disability, and
*“_001”* indicates it is an estimate of the total disabled veterans,
meaning “greater than 0% disability.”
# Getting ACS data for disables Veterans in Va Beach
vabeach_vets <- get_acs(
geography = "tract", # Data is available at the "tract" level
variable = "B21100_001", # Total Disabled Vets
state = "VA",
county = "Virginia Beach",
year = 2021,
geometry = TRUE
)
##
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 26%
|
|=================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|============================ | 40%
|
|============================= | 41%
|
|============================== | 42%
|
|=============================== | 44%
|
|================================ | 45%
|
|================================= | 46%
|
|================================= | 48%
|
|================================== | 49%
|
|=================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|===================================================== | 75%
|
|====================================================== | 77%
|
|======================================================= | 78%
|
|======================================================== | 79%
|
|========================================================= | 81%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 86%
|
|============================================================= | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 99%
|
|======================================================================| 100%
The first plot is interactive and uses mapview to
display the count of disabled veterans per census tract in Va Beach.
Prior to plotting, given the amount of water in this coastal community,
the water was removed using erase_water, but when
attempting to run the code through Knit to plot in
mapview, an error of “node stack overflow” was continually
returned, despite the code working fine when each section is run
individually. To account for this, the first figure is the interactive
plot without the water erased. The second figure was saved as an HTML
using mapshot and is provided as a separate file (I was
unable to add the HTML file to RMarkdown document and standard JPGs
removed any data).
# Plotting the data using Mapview
vabeach_vets_nowater <- erase_water(vabeach_vets,
area_threshold = 0.9,
year =2021)
vabeach_vets_plot <- mapview(vabeach_vets,
zcol = "estimate",
map.type = "Stamen.TonerLite", # Changing basemap
col.regions = brewer.pal(9, "OrRd"), # Adjusting color palete
layer.name = "Disabled Vets ACS 2017-2021" # Title of layer
)
vabeach_vets_plot
The final plot depicts disabled veterans in Va Beach using graduated symbols. Graduated symbols was chosen over choropleth because there is no population to show the relative numbers of disabled vets (i.e. the percentage of the population).
The first step is to convert the disabled vet count associated with
the polygons to points using st_centroid. To make the plot
interactive, the girafe function from ggiraph
package is used.
# Creating a graduated symbol map with ggplot
vet_centroids <- st_centroid(vabeach_vets) # Converting polygon data to points
gg_vets <- ggplot() +
geom_sf(data = vabeach_vets,
color = "black",
fill = "lightgray") + # Basemap
geom_sf(data = vet_centroids, aes(size = estimate),
alpha = 0.5,
color = "red") + # Adjusting transparency and color
theme_void() +
labs(title = "Disabled Veterans by Census tract",
subtitle = "2017-2021 ACS, Virginia Beach, VA",
size = "ACS Estimate") +
scale_size_area(max_size = 8)
girafe(ggobj = gg_vets) %>%
girafe_options(opts_hover(css = "fill:cyan;"))
Figure 2. Graduated symbol plot of disabled veterans in Virginia Beach, VA.
Examining the data in both the interactive map and graduated symbol plot, there is a higher concentration of disabled veterans in western Va Beach. These locations tend to have easier access to interstates and are centrally located relative to the 3 main Naval Bases in Hampton Roads - Naval Station Norfolk, Joint Expeditionary Base Little Creek and Naval Air Station Oceana. There are high concentrations of disabled veterans in other locations of Va Beach, so proximity to all 3 naval bases and access to interstate is purely speculation.