New Lesson: Mapping Historic Census Data in R

[This article was first published on » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today I am happy to announce a new lesson for my free email course Learn to Map Census Data in R. This lesson explains how to get and map historic census data in R. While I had intended this lesson to only go to new signups, it looks like my email provider sent it (along with resending the conclusion email!) to anyone who ever took the course. I apologize for this! For reference, here is the lesson:


Exercise: Map the Population of US States in 2010.

In lesson 2 we used two objects to analyze state demographics:

  1. ?df_pop_state, which has data from the 2012 5-year America Community Survey (ACS)
  2. ?df_state_demographics, which has data from the 2013 5-year ACS

To get data from other years you need to access the US Census API. To do that:

  1. Fill out this form to get a Census API Key. They will email you a key.
  2. When you get your key, type the following in R:

api.key.install("<your key>")


We can now use the function ?get_state_demographics to get data from other surveys. For example, this code will get data from the 2010 5-year ACS:



df_2010_demographics = get_state_demographics(2010)


Creating a map of 2010 population estimates is now simple:


df_2010_demographics$value = 

    title = “2010 State Population Estimates”, 
    legend = “Population”)


Exercise: Make a map showing the Percent Hispanic of Counties in Texas in 2011.


We will get the data with the function ?get_county_demographics, which works analogously to get_state_demographics:


df_2011_demographics = get_county_demographics(2011)

df_2011_demographics$value = 

    title      = "Texas 2011 CountynPercent Hispanic",
    legend     = "Percent Hispanic",
    state_zoom = "texas")


Homework: Use the function ?get_zip_demographics to make a map of some demographic in San Francisco County (FIPS code 6075) in 2011. get_zip_demographics is in the package choroplethrZip. Tweet the resulting image to me (@AriLamstein) with the hashtag #censuscourse.

Subscribe and get my free email course: Mapping Census Data in R!
100% Privacy. We don’t spam.

The post New Lesson: Mapping Historic Census Data in R appeared first on

To leave a comment for the author, please follow the link and comment on their blog: » R. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)