Skip to main content

All exercises

Every chapter exercise in the book, in the order you meet them. Each one sits right after its chapter, and each takes about an hour. Open the exercise page for the instructions (Purpose, Task, and Criteria for success), then download the .Rmd file and work through it in RStudio.

Chapters 1, 20, 23, and 24 have no exercise.

Unit 1: R and Spatial Data Science

Is Your Computer Ready for R?
Chapter 2, R, RStudio, and R Markdown
You’ll find out exactly which version of R your computer runs, whether it is new enough for this course, and how to keep it up to date for the rest of the semester.
Download r-setup-exercise.Rmd

North Carolina Cities in Numbers
Chapter 3, R Basics
You’ll learn how much six North Carolina cities grew between the 2010 and 2020 Censuses.
Download r-basics-exercise.Rmd

Picking Out Cities and States
Chapter 4, Indexing Vectors and Data Frames
You’ll find out how North Carolina’s median income compares with the other states, and which states saw their median income fall between 2010 and 2015.
Download indexing-exercise.Rmd

How Fast Are NC Cities Growing?
Chapter 5, Blocks, Loops, and Functions
You’ll estimate how many years it would take six North Carolina cities to double in size if they kept growing at their 2010 to 2020 rate, and sort the states into low, middle, and high income groups.
Download blocks-loops-functions-exercise.Rmd

Unit 2: Into the Tidyverse

Flights to North Carolina
Chapter 6, Into the Tidyverse: glimpse, filter, and the Pipe
You’ll find out how many flights left New York City for North Carolina’s airports in 2013, which North Carolina airport got the most, and how many of the flights to Raleigh–Durham were cancelled.
Download filter-pipe-exercise.Rmd

The Fastest Flight to North Carolina
Chapter 7, Into the Tidyverse: arrange, distinct, select, and mutate
You’ll find out which airlines and routes connected New York with North Carolina in 2013, which flight to North Carolina left latest, and which was the fastest.
Download arrange-select-mutate-exercise.Rmd

Which North Carolina Airport Has the Worst Delays?
Chapter 8, Into the Tidyverse: summarize, group_by, and drop_na
You’ll compare delays and cancellations at North Carolina’s five airports, find out which airlines were most often late, and see how much the “average speed” of a route depends on how you average it.
Download summarize-group-by-exercise.Rmd

Picturing Flights to North Carolina
Chapter 9, Into the Tidyverse: Graphs with ggplot2
You’ll see whether flights that leave late also arrive late, which New York airports serve North Carolina, and which months were worst for delays to each North Carolina airport.
Download ggplot-exercise.Rmd

Unit 3: Maps and Geographic Data

People, Cities, and Rivers
Chapter 10, Thematic Maps with tmap
You’ll map where people live in the United States, compare a map of population with a map of population density, and map the world’s largest cities on top of life expectancy.
Download tmap-exercise.Rmd

Points, Lines, Polygons, and Grids
Chapter 11, What Is Geographic Data?
You’ll work with New Zealand’s regions, its highest peaks, and an elevation grid of one of Auckland’s volcanoes, and see how the same place can be stored in very different ways.
Download geographic-data-exercise.Rmd

Measuring North Carolina
Chapter 12, Location and Coordinate Systems
You’ll measure the area of North Carolina and the distances between five of its cities, and find out how much the map projection on your phone (Web Mercator) exaggerates them.
Download coordinate-systems-exercise.Rmd

Median Income at Three Scales
Chapter 13, Census Data and APIs
You’ll map median household income across the United States, across North Carolina’s 100 counties, and across the census tracts of Orange County, and see how the story changes with scale, and why the smallest areas are the least certain.
Download census-exercise.Rmd

Medical Facilities from NC OneMap
Chapter 14, ArcGIS Data with arcpullr
You’ll find out how many licensed medical facilities North Carolina has, what kinds they are, and how Orange and Durham counties compare.
Download arcpullr-exercise.Rmd

Unit 4: Spatial Analysis

Matching Tables by Name and by Place
Chapter 15, Joins: Attribute and Spatial
You’ll attach Census populations to North Carolina cities, map how median income changed across the states, find the London boroughs with the most bike-share stations, and find the nearest airport to ten North Carolina cities.
Download joins-exercise.Rmd

Getting to Know North Carolina’s Births
Chapter 16, Exploratory Spatial Data Analysis
You’ll describe how births and sudden infant deaths (SIDS) were spread across North Carolina’s 100 counties in the 1970s, find out which counties are outliers and why, and see where the rate of SIDS was highest.
Download esda-exercise.Rmd

Where Is the Center of North Carolina’s Births?
Chapter 17, Spatial Descriptive Statistics
You’ll find the geographic center of North Carolina’s 100 counties and the center of its births in the 1970s, see how far apart they are and why, and check whether the center of births moved between 1974–78 and 1979–84.
Download spatial-statistics-exercise.Rmd

Unit 5: Statistics and Science

Does Income Differ by Region?
Chapter 18, Comparing Groups: p-values and ANOVA
You’ll test whether median income differs between the four Census regions of the United States, and find out how much the answer depends on one unusual place.
Download anova-exercise.Rmd

What Explains House Values?
Chapter 19, Linear Regression
You’ll find out how much the number of rooms, the share of low-income residents, crime, and being on the Charles River explain the value of homes in the census tracts of Boston, and where the model gets it most wrong.
Download regression-exercise.Rmd

Who Are My Neighbors?
Chapter 21, Distance and Neighborhoods
You’ll find out which states have the most and fewest neighbors, why four states in the Southwest are neighbors under one rule but not another, and whether a state’s income looks like its neighbors’ incomes.
Download distance-neighborhoods-exercise.Rmd

Is It Clustered?
Chapter 22, Spatial Clustering and Spatial Autocorrelation
You’ll find out whether London’s bike-hire docks are clustered, how strongly income and poverty cluster among U.S. states, and where the hot and cold spots of income are.
Download spatial-autocorrelation-exercise.Rmd