Week 2

Visualizing spatial data with {ggplot2}

weeks
Published

September 4, 2024

Summary
Learn to make plots and maps using the {ggplot} package. Visualization is a key method in learning how to explore, tidy, and interpret data.

Overview

This week is all about making plots and maps using the {ggplot} package. Learning to visualize data is a great place for start learning how to exploring data analytically and understanding the value of tidy data when working with R.

Key Objectives

  • Introduce the concept of a “pipe” (%>% or |>) and how and when to use it
  • Introduce the concept of the “grammar of graphics”
  • Practice plotting and mapping data with {ggplot2}
  • Practice mapping data with {mapview}

Key Skills

  • Using keyboard shortcuts in RStudio
  • Creating plots using ggplot(), aes(), and geom_() functions
  • Creating static maps using geom_sf() and coord_sf()
  • Creating interactive maps using mapview()
  • Using theme_ functions to customize the appearance of a plot
  • Using labs() to add labels to a plot

Prepare

Required readings

Optional readings

  • Elliot Bentley “The Web as Medium for Data Visualization,” in The Data Journalism Handbook: Towards A Critical Data Practice, ed. Liliana Bounegru and Jonathan Gray, 2nd ed. (Amsterdam University Press, 2021), 138–142, doi:10.2307/j.ctv1qr6smr.29.
  • ggplot2 workshop part 1 and part 2 with Thomas Lin Pedersen, 2020
  • Ch. 9 Mapping in Robin Lovelace, Jakub Nowosad, and Jannes Muenchow Geocomputation with R, 2nd ed. (CRC Press, 2025), https://r.geocompx.org.

Participate

🖥️ Visualizing spatial data with {ggplot2}

Practice

🛠️️ Exercise 02