Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created December 20, 2017 16:44
Show Gist options
  • Save walkerke/146dc66f42c0689d6a22eddca0d7dc22 to your computer and use it in GitHub Desktop.
Save walkerke/146dc66f42c0689d6a22eddca0d7dc22 to your computer and use it in GitHub Desktop.
library(tidycensus)
library(tidyverse)
library(tigris)
library(sf)
options(tigris_class = "sf")
options(tigris_use_cache = TRUE)
rent <- get_acs(geography = "tract", variables = "DP04_0134",
state = c("WA", "OR", "CA"), geometry = TRUE)
metros <- core_based_statistical_areas(cb = TRUE) %>%
filter(GEOID %in% c("38900", "41860", "42660")) %>%
select(metro_name = NAME)
wc_rent <- st_join(rent, metros, join = st_within,
left = FALSE) %>%
st_transform(26910)
library(viridis)
ggplot(wc_rent, aes(fill = estimate, color = estimate)) +
geom_sf() +
facet_wrap(~metro_name, scales = "free", nrow = 1) +
theme_minimal() +
theme(aspect.ratio = 1) +
scale_fill_viridis() +
scale_color_viridis()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment