choroplethrZip v1.3.0: easier demographics, national maps


choroplethr v3.0 is now available on github. You can get it by typing

# install.packages("devtools")
install_github('arilamstein/[email protected]')

Version 1.3.0 has two new features:

  1. Data frame df_zip_demographics contains eight demographic statistics about each ZIP Code Tabulated Area (ZCTA) in the US. Data comes from the 2013 5-year American Community Survey (ACS).
  2. Function ?get_zip_demographics will return a data.frame with those same statistics from an arbitrary ACS.


Here is how to access the data:


 [1] "region" "total_population" "percent_white" 
 [4] "percent_black" "percent_asian" "percent_hispanic" 
 [7] "per_capita_income" "median_rent" "median_age"

summary(df_zip_demographics[, "total_population"])
 Min. 1st Qu. Median Mean 3rd Qu. Max. 
 0    721     2802   9517 13000   114700

Mapping the Data

Here is a program which will create national maps of the data:

# for each column in the data.frame
for (i in 2:ncol(df_zip_demographics))
 # set the value and title
 df_zip_demographics$value = df_zip_demographics[,i]
 title = paste0("2013 ZCTA Demographics:n",

 # print the map
 choro = zip_choropleth(df_zip_demographics, title=title)

Note that national zip maps can take a few minutes to render. Here is the output.









New Vignette

Additionally, I have created a new vignette about these features.

spacedman says April 29, 2015

Can you fix the aspect ratio so the US doesn’t look that squashed?

Gopala Tumuluri says April 29, 2015

This is an awesome package and I am already enjoying using it. Thank you for the work. More examples on color scaling (different quantiles) and also getting flatter shaped maps would help choropleth newbies like me.

    Ari Lamstein says April 29, 2015

    Thank you for your comment. There are a few vignettes on the main choroplethr page which go thru changing the colors:

    You might be particularly interested in the state choropleth vignette, because it shows dealing with string/factor values (presidential candidates):

    If you type:

    > library(choroplethr)
    > ?state_choropleth

    You will see an example of creating a choropleth which shows which states have less than or more than 1 million people. Essentially, it converts the numeric values (population) to string/factor (e.g. ” 1M”) before calling state_choropleth().

    The projection issue is something that I’m working now. For whatever reason, R crashes when I try to manually set a projection. See here for details:!topic/choroplethr/PfN5eqtLlgs

    If you have any specific questions, the best place to get help is the choroplethr google group:!forum/choroplethr

      Gopala Tumuluri says April 29, 2015

      Appreciate it! I need to and am using the zip level one from one of your other vignettes with state_zoom. It works great for palette=5, but the scale_color_brewer seems to pick certain quantiles of the data. I need to modify them to scale the data differently. This may be more a ggplot2 related issue and not the choroplethrzip one. But, I just can’t seem to get it.

drirfani99 says April 29, 2016

Ari- This tool looks amazing! Am having trouble installing the zip code level data in R. Receiving the following error: ERROR: dependency ‘Hmisc’ is not available for package ‘choroplethrZip’

Any suggestions on how to bypass this error? Sorry for the rudimentary question.

    Ari Lamstein says April 29, 2016

    Can you confirm which version of choroplethrZip you’re trying to install. This post is for v1.3.0 but the current version is v1.5.0. See

Comments are closed