choroplethr v3.1.0: Better Summary Demographic Data

By on May 5th, 2015 in Blog

Today I am happy to announce that choroplethr v3.1.0 is now on CRAN. You can get it by typing the following from an R console:


This version adds better support for summary demographic data for each state and county in the US. The data is in two data.frames and two functions. The data.frames are:

  • ?df_state_demographics: eight values for each state.
  • ?df_county_demographics: eight values for each county.

These statistics come from the US Census Bureau’s 2013 5-year American Community Survey (ACS). If you would like the same summary statistics from another ACS you can use these two function:

  • ?get_state_demograhpics
  • ?get_county_demograhpics

For more information on the ACS and choroplethr’s support for it, please see this page.

Relation to Previous Work

In many ways this update is a continuation of work that began with my April 7 guest blog post on the Revolution Analytics blog. In that piece (Exploring San Francisco with choroplethrZip) I explored the demographics of San Francisco ZIP Codes. Because of the interest in that piece, I subsequently released the data as part of the choroplethrZip package. This update simply brings that functionality to the main choroplethr package.

Note that caveats apply to this data. ACS data represent samples, not full counts. I simplify the Census Bureau’s complex framework for dealing with race and ethnicity by dealing with only White not Hispanic, Asian not Hispanic, Black or African American not Hispanic and Hispanic all Races. I chose simplicity over completeness because my goal is to demonstrate technology.

Explore the Data Online

You can explore this data with a web application that I created here. The source code for the app is available here. This app demonstrates some of my favorite ways of exploring demographic data:

  • Using a boxplot to explore the distribution of the data
  • Exploring the data at both the state and county level
  • Using choropleth maps to explore geographic patterns of the data
  • Allowing the user to change the number of colors used:
    • 1 color uses a continuous scale, which makes outliers easy to see
    • Using 2 thru 9 colors puts an equal number of regions in each color. For example, using 2 colors shows values above and below the median

In my opinion, datasets like this really lend themselves to web applications because there are so many ways to visualize the data, and no single way is authoritative.

Selected Images

One of my biggest surprises when exploring this dataset was to discover its strong regional patterns. For example, the regions with the highest percentage White not Hispanic residents tend to be in the north central and north east. The regions with the highest percentage of Black or African American not Hispanic residents is in the south east. And the regions with the highest concentration of Hispanic all Races is in the south west:




Switching to counties shows us the variation within each state. And switching to a continuous scale highlights the outliers.



6 thoughts on “choroplethr v3.1.0: Better Summary Demographic Data

  1. Tanya says:

    The interactive web application is great! I use ACS and Census data to look for associations between disease incidence (the focus of my work) and area based poverty measures, such percent living below the poverty line (at the Census Tract level in San Francisco). I enjoyed reading your piece on the Revolution Analytics blog. Any plans to include census tract level data (rather than zipcode) in future versions of the choroplethr package? Thanks!

    1. Ari Lamstein says:


      Thanks for the kind words! I am interested in the correlations that you describe – do you have a link to any publications about it?

      I am indeed interested in drilling farther down. Here is the link to the census bureau’s page on shapefiles for census tracts:

      It appears that it there shapefiles are by state, though. So it might not be possible to ship a package that includes the whole nation. Were you just interested in California?

  2. stbarlow says:

    Hi, The url for the exploration app,, results in a 404.

    1. Ari Lamstein says:

      Unfortunately, you are correct. This post is over a year old, and in the interim my hosting bill for shiny apps became very expensive and I discontinued the service. If you are interested in learning how to create shiny apps like this, I do have a course on it in my Membership site:

      1. Andrew says:

        Hi. I have attempted to install/load choroplethr but R still cannot recognize the new functions, like zip_choropleth_acs. I got my own ACS key too but that didn’t help. R seems to recognize the deprecated functions but tells me I should use the new ones, which it . . . doesn’t recognize. Any advice?

        1. Ari Lamstein says:

          All zip related functions are now part of the choroplethrZip package. There is documentation on the github page for that package. Can you take a look at the documentation on the github page and tell me if that helps: What this comment, and other recent comments, is highlighting to me is that I really need to have a separate section on my website for all my open source projects, including up to date documentation. I know that this page was mentioned on a prominent blog recently and so is getting a lot of traffic, but it’s fairly out of date. Sorry to be brief – I’m writing this on a plane and they just announced that we’re descending.

Leave a Reply