Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created November 17, 2022 12:19
Show Gist options
  • Save walkerke/a929366fd147306112d99bf6a57fd026 to your computer and use it in GitHub Desktop.
Save walkerke/a929366fd147306112d99bf6a57fd026 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("Lato", "Lato")
dat <- get_acs(
geography = "county",
variables = "DP02_0153P",
geometry = TRUE
) %>%
mutate(no_computer = 100 - estimate) %>%
filter(str_sub(GEOID, 1, 2) != "72") %>%
shift_geometry()
ggplot(dat, aes(fill = no_computer)) +
geom_sf(color = NA) +
theme_void(base_family = "Lato") +
scale_fill_viridis_c(labels = scales::label_percent(scale = 1),
option = "inferno") +
labs(title = "Percent of county population without a computer at home\n",
caption = "2016-2020 ACS | tidycensus R package | @kyle_e_walker\n",
fill = "") +
theme(plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
legend.position = "top",
legend.direction = "horizontal",
legend.key.width = unit(0.5, "in"),
legend.key.height = unit(0.1, "in"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment