Skip to content

Instantly share code, notes, and snippets.

@walkerke
Last active February 5, 2019 17:04
Show Gist options
  • Save walkerke/5cc81e885d87ec36fc3e2e15b0eb6b01 to your computer and use it in GitHub Desktop.
Save walkerke/5cc81e885d87ec36fc3e2e15b0eb6b01 to your computer and use it in GitHub Desktop.
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",
endyear = 2016) %>%
filter(summary_est > 2000000) %>%
mutate(NAME = gsub("Metro Area", "", NAME)) %>%
ggplot(aes(x = estimate, y = reorder(NAME, estimate))) +
geom_point(color = "navy", size = 2.5) +
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment