Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Created March 16, 2020 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hepplerj/76fd402f403d1fbb3be7003bab37f717 to your computer and use it in GitHub Desktop.
Save hepplerj/76fd402f403d1fbb3be7003bab37f717 to your computer and use it in GitHub Desktop.
Percentage of residents who take public transportation to work
library(tidycensus)
library(tidyverse)
# If not set, un-comment below and install your Census API key (https://api.census.gov/data/key_signup.html)
# census_api_key("YOUR KEY HERE", install = TRUE)
get_acs(geography = "metropolitan statistical area/micropolitan statistical area",
variables = "DP03_0021PE",
summary_var = "B01003_001",
survey = "acs1",
year = 2016) %>%
filter(summary_est > 2000000) %>%
mutate(NAME = gsub("Metro Area", "", NAME)) %>%
ggplot(aes(x = estimate, y = reorder(NAME, estimate))) +
geom_point(color = "steelblue", size = 2) +
labs(title = "Percentage of residents who take public transportation to work",
subtitle = "2016 1-year ACS estimates",
y = "",
x = "ACS estimate (percent)",
caption = "Source: ACS Data Profile variable DP03_0021P via the tidycensus R package") +
theme_minimal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment