An introduction to the R ggplot2 package

Session Aim

This code clinic will provide an introduction to the “grammar of graphics” approach to generating data visualisations as implemented in the ggplot2 package in R.

Session Content

This session will cover the following topics: an introduction to ggplot2 syntax, using ggplot2 “layers” to build plots, aesthetically mapping plotting elements (e.g. position, color, size) to variables in R data frames, creating visually pleasing plots by adjusting the theme layer, and additional R packages that are compatible with ggplot2 objects.

Session Objectives

At the end of the session, participants will be able create common plots from quantitative and categorical data (i.e. histograms, scatterplots, bar charts) map data frame variables to specific features within plots, customize plot aesthetics, and combine multiple ggplot2 objects.