Maps in R

A quick course on how to discover spatial patterns with common map types.

There are many ways to map geographic data in R, and with all the packages available, it can seem like a hodgepodge of items with no clear spot to begin. This doesn’t have to be the case. With a couple of map-specific packages in hand and some clear goals, you can accomplish the bulk of your mapping tasks.

Who This Course Is For

This course is for those who want to make maps in R. While experience in R is helpful, I don’t assume that you already know your way around.

Learning Objectives

The goal of this course is to teach you to make maps in R relatively quickly. You will:

  • Get setup in R.
  • Learn mapping basics.
  • Work with spatial datasets.

I emphasize speed, so that you can apply maps to your own data for work and play.

Course Outline

After setup, there are four main lessons with working code examples and real data.

  • Setup
  • Drawing Boundaries
    • A Straightforward But Limited Method
    • Using Shapefiles
    • Map Projections
    • Additional Resources
  • Mapping Locations
    • Points
    • Symbols
    • Lines
  • Choropleth Map
    • Loading the Data
    • Joining the Data to Regions
    • Defining Colors
    • Drawing the Map
    • Missing Data
    • Adding a Legend
  • Making More Maps
    • Multiple Maps
    • Small Multiples
    • Helper Functions for Faster Maps

Why R

R is a statistical computing language that lets you explore and analyze datasets. You can quickly use established chart types in a few seconds, or you can build your own from scratch. Or do both.

Instead of working within the limits of click interfaces, you get the flexibility to make just about any type of chart.

Course Format

Self-guided. Learn by example. Work with real datasets. Additional resources are provided at the end of each lesson for more depth.

Suggested duration: 1 week, but take as little or as much time as you want since the course is self-guided.


Your Guide

I’m Nathan Yau. I have a PhD in statistics from UCLA, with a focus on visualization for presenting data to everyone. My visualization work leans towards analytical but has also reached millions of people. Find more about me here.

Membership

Become a member on FlowingData to get full access to this course and others, plus hundreds of tutorials and guides. Learn to make any chart, the process of data design, and how to communicate with data.

Become a member →