Skip to content

Instantly share code, notes, and snippets.

@dgkeyes
Created March 24, 2022 21:47
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 dgkeyes/a9b3122b77f80684f557e986f011d973 to your computer and use it in GitHub Desktop.
Save dgkeyes/a9b3122b77f80684f557e986f011d973 to your computer and use it in GitHub Desktop.
pal_state_pop <- colorNumeric("viridis", us_contiguous$estimate)
label_state <- function(state, pop){
str_glue("{state} with population of {pop}")
}
us_contiguous %>%
leaflet() %>%
addPolygons(weight = 1,
color = "white",
fillColor = ~pal_state_pop(estimate),
fillOpacity = 1,
popup = ~label_state(NAME, estimate)) %>%
addLegend(pal = pal_state_pop,
values = ~estimate,
opacity = 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment