Week 3: Graphing with {ggplot2}

Author

Josie Griffin ’09

Published

February 24, 2025

Agenda

Today we’ll be learning how to make graphs with the package {ggplot2}, which is the most popular graphing option within R. You will learn some degree of graph customization, but in R you can change almost any aspect of a graph, so it is impossible to go over everything. We will cover some of the most common graph changes and you will be provided with resources to go further.

After today you should be able to:

  • understand the basic structure of a ggplot command

  • know how to change between plot types

  • use color to separate groups on graphs to make them more informative

  • change axis labels

  • know where to find more resources for altering and adding to graphs


This workshop contains code that can be run solely inside this web document, but you are encouraged to copy the code to either the Reed R Server or your desktop version of R so that you can save it as a file of your own. The ability to run code in this web-based document is made possible through the package {webr}. The code will run in the browser the same way it would in RStudio, so you can save variables, see error messages, see graphs, etc. To run the code, you can either press the “Run Code” button or highlight sections and run them by pressing control or command and enter, as you would in RStudio.

Here’s an example:

(Run Code and the green play button may not appear right away, there may be a yellow circle while the interface loads. Just wait until you see the green button to do anything.)


This workshop is part of a series. If you would like to see previous workshops or see the topics of future workshops, please check the workshop schedule. All workshops are held on Mondays at 5:30 in ETC 208.

If you have questions beyond what is covered in the workshops, please feel free to contact Josie at either griffinj@reed.edu or data@reed.edu.

You can also drop in to the open hours at the DataLab for help with R or any other quantitative subject!