Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created November 4, 2022 15:45
Show Gist options
  • Save walkerke/c56ee410691f0b808d66c571ae054431 to your computer and use it in GitHub Desktop.
Save walkerke/c56ee410691f0b808d66c571ae054431 to your computer and use it in GitHub Desktop.
library(tidycensus)
library(tigris)
library(tidyverse)
library(showtext)
options(tigris_use_cache = TRUE)
font_add_google("Roboto", "Roboto")
showtext_auto()
ukrainian <- get_acs(
geography = "county",
variables = "B04006_092",
summary_var = "B04006_001",
geometry = TRUE
) %>%
mutate(percent = 100 * (estimate / summary_est)) %>%
shift_geometry()
ggplot(ukrainian, aes(fill = percent)) +
geom_sf() +
scale_fill_viridis_b(option = "cividis", breaks = c(0, 0.5, 1, 1.5, 2, 3),
label = scales::label_percent(scale = 1)) +
theme_void(base_size = 14, base_family = "Roboto") +
labs(title = "Percent of county population with Ukrainian ancestry",
subtitle = "2016-2020 American Community Survey",
caption = "@kyle_e_walker | tidycensus R package | Estimates subject to margin of error",
fill = "Percent") +
theme(plot.margin = margin(0, 0.5, 0, 0.5, unit = "cm"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment