Created
November 15, 2022 14:07
-
-
Save walkerke/7c3701d60c40d98dce36378f5adab2ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidycensus) | |
library(tidyverse) | |
library(tigris) | |
library(sf) | |
library(mapboxapi) | |
library(showtext) | |
options(tigris_use_cache = TRUE) | |
font_add_google("Lato", "Lato") | |
food_service <- get_acs( | |
geography = "tract", | |
variables = c("C24010_001", "C24010_024", "C24010_060"), | |
geometry = TRUE, | |
state = "NY", | |
county = c("New York", "Bronx", "Richmond", "Kings", "Queens"), | |
output = "wide" | |
) %>% | |
st_transform(6538) %>% | |
erase_water() %>% | |
st_cast("MULTIPOLYGON") %>% | |
mutate(percent = 100 * ((C24010_024E + C24010_060E) / C24010_001E)) | |
# Custom basemap build in Mapbox Studio | |
# See mapboxapi docs for more details / how to create your own | |
basemap <- layer_static_mapbox(location = food_service, | |
style_id = "clai9lqmv000214nymy65fwyn", | |
username = "kwalkertcu") | |
ggplot(na.omit(food_service), aes(fill = percent)) + | |
basemap + | |
geom_sf(color = NA) + | |
theme_void(base_family = "Lato", base_size = 14) + | |
scale_fill_viridis_c(labels = scales::label_percent(scale = 1)) + | |
labs(title = "Food service as % of workforce", | |
subtitle = "Census tracts, New York City", | |
caption = "2016-2020 ACS | @tidycensus R package | @kyle_e_walker", | |
fill = "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment