Created
March 23, 2023 20:01
-
-
Save walkerke/eed2d5df8c30beca2075e65b2a7d5dfc to your computer and use it in GitHub Desktop.
This file contains 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) | |
options(tigris_use_cache = TRUE) | |
state_names <- c(state.name, "District of Columbia") | |
names(state_names) <- state_names | |
tictoc::tic() | |
age_maps <- map(state_names, ~{ | |
age_data <- get_acs( | |
geography = "tract", | |
variables = "B01002_001", | |
state = .x, | |
geometry = TRUE | |
) | |
ggplot(age_data, aes(fill = estimate)) + | |
geom_sf(color = NA) + | |
theme_void() + | |
scale_fill_viridis_c(option = "magma") + | |
labs(title = .x, | |
subtitle = "Median age, 2017-2021 ACS", | |
fill = "Estimate") | |
}) | |
tictoc::toc() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment