U.S. flag

An official website of the United States government

Skip Header
Webinars
Resources
REQUEST A DATA TRAINING

Webinars
Live and recorded classes led by Census Bureau instructors on a variety of topics.

Mapping Census Bureau Data in R with Choroplethr

Learn how to map data from the American Community Survey using R.

Developed and presented by Ari Lamstein.

 

Skill Level: Intermediate

Duration: 3-4 hours

Description

This course will teach you how to visualize data from the US Census Bureau’s American Community Survey (ACS) using the R package Choroplethr.

The introduction will teach you the necessary prerequisites: how to install R, RStudio and the choroplethr package. The module Choroplethr Basics will teach you how to map data in R using the choroplethr package. You will learn how to map a sample dataset, as well as how to customize the map.

In Variables and Vintages you will learn how to access the Census Bureau’s API, map data from other years and explore more demographic statistics. In the module Data Details you will learn the details of the data you’ve been mapping. This includes learning about the data source (the American Community Survey), how it differs from the Decennial Census, and the amount of data which is available.

Finally, in Learning More you will learn resources to continue learning about both the ACS and Choroplethr.

After completing this course, you will be able to:

    ✓     Create maps of contemporary and historic demographic statistics in R

    ✓     Conduct exploratory data analysis using maps

    ✓     Understand what the American Community Survey is, and how it differs from the Decennial Census

    ✓     Access data via the Census Bureau’s API

Who Should Take this Course?

Data Analysts and Data Scientists who wish to learn more about R, Census Data or the American Community Survey. Prior knowledge of R is not required, but prior experience with computer programming will be helpful.

Instructor

Ari Lamstein is an R Trainer and Consultant who is located in San Francisco, California. He is the author of several R packages, including choroplethr.

Course Materials

 

 

Beginning of Module 1

 

 

Module 1, Lesson 1: What You Will Learn

This module will teach you the necessary prerequisites: how to install R, RStudio and the choroplethr package.

Module 1, Lesson 2: Installing R

You will need to install the R programming language in order to complete this course. R is completely free.

To install it, first visit r-project.org. Then follow the instructions in the video.

Module 1, Lesson 3: Installing Studio

Many people find that using a program called RStudio makes it easier to program in R.

RStudio is completely free to use. To install it, visit RStudio.com and follow the directions in the video.

Module 1, Lesson 4: Installing Choroplethr

To use choroplethr, you need to install two packages. Go the RStudio “console” pane and type the following:

install.packages("choroplethr")
install.packages("choroplethrMaps")

 

 

Beginning of Module 2

 

 

Module 2, Lesson 1: Loading the Package

This module will teach you how to map data in R using the choroplethr package. You will learn how to map a sample dataset, as well as how to customize the map.

Load the packages by typing the following from the R Console:

library(choroplethr)
library(choroplethrMaps)

Verify that the packages are loaded by looking at the “Packages” window. Choroplethr and ChoroplethrMaps should have a checkmark next to them.

Module 2, Lesson 2: Viewing Example Data

To view the example data, type the following:

library(choroplethr)
library(choroplethrMaps)

data(df_pop_state)

# show the data in the console
df_pop_state

# load the data in the Viewer
View(df_pop_state)

Module 2, Lesson 3: Mapping Example Data

To create a sample map using choroplethr, type the following:

library(choroplethr)
library(choroplethrMaps)

data(df_pop_state)
state_choropleth(df_pop_state)

Module 2, Lesson 4: Customizing Maps

NOTE: Due to changes in Google's API, you need to do the following before running the example below.

  1. Register for a free google API key at https://cloud.google.com/maps-platform/
  2. Enter that key in R by typing the following:
  3. library(ggmap)
    register_google("< your api key >")

  4. Install the R package "mapproj" by typing the following:
  5. install.packages("mapproj")

Due to recent changes in the Google Maps API, the instructions for the last example require minor changes to run. Please download the file below to see the new code.

Download the code from this lesson!

 

 

Beginning of Module 3

 

 

Module 3, Lesson 1: More Variable

In this module you will learn how to access the Census Bureau’s API, map data from other years and explore more demographic statistics.

Download the code used in this lesson!

Module 3, Lesson 2: More Years

Download the code used in this lesson!

Module 3, Lesson 3: Calculating Percent Change

Download the code used in this lesson!

Module 3, Lesson 4: Mapping Percent Change

Download the code used in this lesson!

 

 

Beginning of Module 4

 

 

Module 4, Lesson 1: Introduction to ACS

In this module  you will learn the details of the data you’ve been mapping. This includes learning about the data source (the American Community Survey), how it differs from the Decennial Census, and the amount of data which is available.

Module 4, Lesson 2: Choosing a Span

Each year the ACS releases data for 1- and 5-year spans. This page from the Census Bureau provides guidance on when to use each span. The choroplethr function ?get_state_demographics has a parameter called span that lets you choose which estimate to get.

Module 4, Lesson 3: Introduction to Tables

  1. Type get_state_demographics (without parentheses) into the R console to see how the function works.
  2. Do a Google search for table B03002.
  3. View the list of all tables for all ACS surveys.

Module 4, Lesson 4: Getting Specific Tables

Download the code from this lesson!

Module 4, Lesson 5: Getting Margin of Error

Download the code from this lesson!

 

 

Beginning of Module 5

 

 

Module 5: Learning More

In this module you will learn resources to continue learning about both the ACS and Choroplethr.

To learn more about the American Community Survey visit the official American Community Survey site.

To learn more about choroplethr visit choroplethr.com.

Congratulations! You finished the course!

Share your accomplishment on your social media by downloading this certificate or badge!

Copy Text:

I just finished the Mapping Census Bureau Data in R with Choroplethr Course with Census Academy! Be sure to check out their free resources! 

#CensusBureau #CensusData #CensusAcademy #AmericanCommunitySurvey #ACS #Choroplethr

Page Last Revised - October 20, 2022
Is this page helpful?
Thumbs Up Image Yes Thumbs Down Image No
NO THANKS
255 characters maximum 255 characters maximum reached
Thank you for your feedback.
Comments or suggestions?

Top

Back to Header