Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created February 5, 2018 15:51
Show Gist options
  • Save walkerke/da85b966bfe959371be021e9d977d439 to your computer and use it in GitHub Desktop.
Save walkerke/da85b966bfe959371be021e9d977d439 to your computer and use it in GitHub Desktop.
library(tidycensus)
library(tidyverse)
library(extrafont)
info <- get_acs(geography = "metropolitan statistical area/micropolitan statistical area",
variables = "DP03_0039P",
summary_var = "B01003_001",
survey = "acs1") %>%
filter(summary_est > 1500000) %>%
mutate(NAME = str_replace(NAME, "-.*", "")) %>%
mutate(NAME = str_replace(NAME, ",.*|/.*", ""))
ggplot(info, aes(x = estimate, y = reorder(NAME, estimate))) +
geom_segment(aes(x = -0.2, y = reorder(NAME, estimate),
xend = estimate, yend = reorder(NAME, estimate)),
color = "#386890") +
geom_point(color = "#386890", size = 3) +
theme_minimal(base_family = "Verdana") +
scale_x_continuous(labels = function(x) { paste0(x, "%") },
expand = c(0, 0, 0.02, 0)) +
labs(x = "2016 American Community Survey estimate",
y = "",
title = "Percent employed in the information services industry",
subtitle = "Metropolitan areas with population above 1.5 million",
caption = "Employed, civilian population age 16 and up. Data acquired with the R tidycensus package. Chart by @kyle_e_walker.") +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.title = element_text(face = "bold"),
plot.caption = element_text(size = 7))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment