We are hiring thousands of people for the 2020 Census. Click to learn more and apply.

Skip Header

Component ID: #ti847798910


Mapping Census Bureau Data in R with Choroplethr

Component ID: #ti477341145

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

Component ID: #ti273179896

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

Component ID: #ti1003026840

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.

Component ID: #ti739015236

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 choropelthr.

Course Materials

Component ID: #ti41482126

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

Component ID: #ti207081771

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

Component ID: #ti2124567700

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

Component ID: #ti35810531

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

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

Component ID: #ti1322812099
Component ID: #ti2141194559

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.

Component ID: #ti1147060004

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

Component ID: #ti1584687500

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

Component ID: #ti79342362

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

Component ID: #ti1976437042

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!

Component ID: #ti1434474185
Component ID: #ti1908804451

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.

 

Component ID: #ti813527271

Download the code used in this lesson!

Module 3, Lesson 2: More Years

Component ID: #ti550458470

Download the code used in this lesson!

Module 3, Lesson 3: Calculating Percent Change

Component ID: #ti357904172

Download the code used in this lesson!

Module 3, Lesson 4: Mapping Percent Change

Component ID: #ti1735822964

Download the code used in this lesson!

Component ID: #ti752490115
Component ID: #ti2123441243

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

Component ID: #ti1656980313

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

Component ID: #ti83706214

  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

Component ID: #ti115466053

Download the code from this lesson!

Module 4, Lesson 5: Getting Margin of Error

Component ID: #ti296064201

Download the code from this lesson!

Component ID: #ti1778273461
Component ID: #ti184305359

Module 5: Learning More

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

Component ID: #ti469265028

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

To learn more about choroplethr visit choroplethr.com.

Component ID: #ti1852356990

 

Back to top


 

X
  Is this page helpful?
Thumbs Up Image Yes    Thumbs Down Image No
X
Comments or suggestions?
No, thanks
255 characters remaining
X
Thank you for your feedback.
Comments or suggestions?
Back to Header