Created
January 8, 2022 20:58
-
-
Save walkerke/131f9cb2d35967c5f376a0001a9686c1 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) | |
dc_density <- get_acs( | |
geography = "tract", | |
state = "DC", | |
variables = "B01003_001", | |
geometry = TRUE, | |
keep_geo_vars = TRUE | |
) %>% | |
mutate(density_km2 = estimate / (ALAND / 1000000)) | |
ggplot(dc_density) + | |
geom_sf(aes(fill = density_km2)) + | |
theme_void() + | |
scale_fill_viridis_c() + | |
labs( | |
title = "Population density in Washington, DC", | |
fill = "Pop/km2" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment