0

I want a heat map that takes zip codes as the input. From a quick search, it looks like the zipcode package is obsolete. Are there any other work arounds?

Michael
  • 19
  • 3
  • [Previous answer](https://stackoverflow.com/q/50845838/4752675) may help – G5W Jan 18 '20 at 14:28
  • Try the muRL package. Also The zipcode package is not obsolete, it hasn't been updated for awhile and was archived. It is still available with the archived packages here: cran.r-project.org – Dave2e Jan 27 '20 at 02:15

1 Answers1

1

Here's a working alternative to zipcodes, if that's not working / is inactive (I've never used it, though). choroplethrZip has worked for me before. Note it's a link to their Github repo, not CRAN.

# install.packages("devtools")
# library(devtools)
# install_github('arilamstein/choroplethrZip@v1.5.0')
library(choroplethrZip)
library(tidyverse)
data(df_pop_zip)
choro = choroplethrZip::ZipChoropleth$new(df_pop_zip)
region <- c("virginia", "maryland", "district of columbia")
choro$prepare_map()
data(zip.regions)
region_zips = zip.regions[zip.regions$state.name %in% region, "region"]
region_df = choro$choropleth.df[choro$choropleth.df$region %in% region_zips, ]

Example for population:

choro$render_helper(region_df, "", choro$theme_clean()) +
  coord_map() +
  scale_fill_brewer(palette = 'Spectral') +
  labs(fill='Population')

enter image description here

Example with random numbers:

region_df2 <- region_df %>% 
  mutate(
    value = cut_width(runif(nrow(.)), 0.2, boundary = 0)
  )
choro$render_helper(region_df2, "", choro$theme_clean()) +
  coord_map() +
  scale_fill_brewer(palette = 'Spectral') +
  labs(fill='Random numbers')

enter image description here

userABC123
  • 1,460
  • 2
  • 18
  • 31