Intro to Data Visualisation Using R and the Slave Voyages dataset
Overview

This is a beginner’s guide to data visualisation in R using ggplot2. It assumes you have installed R and RStudio and know the absolute basics, such as how to run a line of code and load a package. If you are starting from scratch, see sec-installing-r.
The dataset used throughout is a subset of the Trans-Atlantic Slave Trade Database, curated by the Slave Voyages project. The full database records 36,000 individual slaving voyages between 1514 and 1866. The subset used here focuses on voyages that originated in Britain. The history these data describe is brutal. The figures you will produce show, among other things, mortality rates, age and sex composition of the people forcibly transported, and how the trade scaled with British involvement over time. The tutorial treats the data with the seriousness the subject demands.
Intended learning outcomes
By the end of this book you will be able to:
- Load tabular data into R with
read_csv()and inspect it - Clean variable names and types using
clean_names(),rename(),factor()andmutate() - Build plots in layers using the
ggplot2grammar of graphics - Choose an appropriate plot type for the data at hand
- Customise axes, scales, themes and colours
- Reshape data with
pivot_longer()to plot grouped distributions - Combine plots with
patchwork - Save plots in publication-ready formats with alt text
Citing
If you use this tutorial in teaching or in your own writing, please cite it as:
Nordmann, E. (2026). Intro to Data Visualisation Using R and the Slave Voyages dataset. https://github.com/emilynordmann/slavevoyagedata
If you want a fuller treatment of data visualisation aimed at researchers, see Nordmann et al. (2022), the published article that accompanies the introdataviz tutorial.
Acknowledgement
This tutorial was originally written in 2020 at the request of David Tree for anti-racism curriculum materials. It has been revised for Quarto and updated to current tidyverse practice. The code is available under a Creative Commons Attribution-ShareAlike licence on GitHub and you are welcome to adapt it for your own teaching without further permission.