Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created April 16, 2020 20:09
Show Gist options
  • Save walkerke/1e3e33f6e1521513ebf0c667f5a54d1f to your computer and use it in GitHub Desktop.
Save walkerke/1e3e33f6e1521513ebf0c667f5a54d1f to your computer and use it in GitHub Desktop.
library(tidycensus)
library(mapdeck)
library(sf)
options(tigris_use_cache = TRUE)
tract_median_age <- get_acs(
geography = "tract",
variables = "B01002_001",
state = c(state.abb, "DC", "PR"),
geometry = TRUE
) %>%
dplyr::filter(!is.na(st_dimension(.)))
mapdeck(style = mapdeck_style("light"),
token = Sys.getenv("MAPBOX_TOKEN")) %>%
add_polygon(data = tract_median_age,
fill_colour = "estimate",
legend = TRUE,
tooltip = "estimate",
auto_highlight = TRUE,
legend_options = list(
title = "Median age"
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment