Skip to content
R for the Rest of Us Logo

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

David Keyes David Keyes
January 9th, 2023

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!

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

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

Let us know what you think by adding a comment below.

You need to be signed-in to comment on this post. Login.

Fayyaz Ahmad

Fayyaz Ahmad

January 11, 2023

very informative