How to Make 250+ Plots at the Same Time with R

For the past several years, I’ve worked on a report called Oregon by the Numbers. In this project, I use R to make every single plot in the report: over 250 plots each year.

Screenshot of Oregon by the Numbers

In the time I’ve worked on this project, I’ve become more and more efficient at making these plots. My efficiency comes thanks to the walk() function from the purrr package. This function can be confusing, but if you learn how to use it, you too can make hundreds of plots in just a few lines of code.

As you’ll see in the video below, the process is as follows:

  1. Make a function to make one plot
  2. Create a vector with all options for different plots (in my case, that is all of the 36 counties in Oregon)
  3. Use the walk() function to make one plot for each county

Take a look!

Interested in the code I used in this demo? It’s available on GitHub.

Have any questions? Put them below and we will help you out!