Using the patchwork R package to combine two ggplot2 plots into one figure (CC166)
Channel: Riffomonas Project
Date: 2021-11-24

The patchwork R package is a powerful tool for combining multiple plots into one figure. In this Code Club, Pat will show viewers how to use patchwork to combine a dot chart and barbell chart he creates using ggplot2 into a single figure. Along the way he'll discuss how to give the figure a common title and how to apply a theme across the figure to make an attractive data visual. The question he is trying to answer with these plots is whether people's stated intention to receive the COVID-19 vaccine in October 2020 matched whether they actually received the vaccine as of October of 2021. He'll demonstrate how to build these figures generated using data from Ipsos and Our World in Data that describes COVID-19 vaccination intention and rates by country and day.

In this episode, Pat uses #patchwork, #ggplot2, #theme and more functions from the #ggplot2 and #dplyr #R packages in #Rstudio. The accompanying blog post can be found at https://www.riffomonas.org/code_club/2021-11-24-final-figure.

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/


You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Presenting vaccine intention vs. realization
5:34 Using patchwork to combine figures
7:04 Formatting figures individually vs. jointly
11:41 Adjusting width and heights of individual figures
12:50 Modifying x and y-axis
14:57 Add gridlines with geom_hline
15:52 Simplify country names
17:21 Customize fonts
20:06 Customize x-axis limits and break points