Update (1/8/23) With some great help from jrcalabrese, we were able to determine that the problem I was having stemmed from having zip codes in my sample that were not in the state I was zooming to. This was fixed by filtering the sample for only zip codes in the zoomed state.
There are 2 more things I want to do with this plot:
- Create a manual color palette using...
scale_fill_gradientn(colours = c("#FFFFFF","#f688ee","#000775"))
- Overlay county lines for
AZ_County <- (c("Apache County", "Coconino County", "Mohave County",
"Navajo County", "Yavapai County"))
I have not spent as much time on this question yet, as I am including it in this update.
Here is data and code:
structure(list(
region = c("85324", "85332", "85360", "85362", "85901", "85902", "85911", "85912", "85920", "85923"), value = c(363L, 238L, 75L, 71L, 4454L, 136L, 68L, 31L, 39L, 132L)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), row.names = c(NA, -10L), groups = structure(list(region = c("85324", "85332", "85360", "85362", "85901", "85902", "85911", "85912", "85920", "85923"), .rows = structure(list(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -10L), .drop = TRUE))
zip_choropleth(Pop_Zip,
state_zoom = "arizona",
title = "Test",
legend = "Population"
) +
coord_map()
Original question:
I am trying to create a Zip_Choropleth map.
When I run the code, it just sort of hangs, and ultimately r studio times out. Other questions on this topic seemed dated, so I started this thread. Here is the code I am using. Suggestions?
install_github("arilamstein/choroplethrZip@v1.5.0")
library(choroplethrZip)
region <- c("06360", "11953", "22740", "24277", "34275",
"38671", "40351", "46371","53168","56081", "61615", "61920")
df <- data.frame(region)
Pop_Zip <- df %>%
count(region) %>%
rename(value = n)
zip_choropleth(Pop_Zip,
state_zoom = "arizona",
title = "Test",
legend = "Population") +
coord_map()