How to dynamically add significance bars and stars to a figure in ggplot2 (CC113)
Channel: Riffomonas Project
Date: 2021-06-08

A lot of people add significance bars and stars to their plots using PowerPoint or Illustrator. If the visual changes, they have to repeat the process. In this episode, we'll dynamically add significance bars and stars to a figure generated using ggplot2 with the geom_segment and geom_text functions. Along the way we'll use if_else, case_when, map_dbl, and even create our own function.

Pat will use RStudio and the #geom_segment and #geom_text functions from the #ggplot2 package. The accompanying blog post can be found at https://www.riffomonas.org/code_club/2021-06-08-dynamic-stars-and-bars.
Do you have a figure that you would like to receive a critique or help improving? Let me know and I'd be happy to arrange a guest appearance!

If you're interested in taking an upcoming 3 day R workshop, email me at riffomonas@gmail.com!

R: https://r-project.org
RStudio: https://rstudio.com
Raw data: https://github.com/riffomonas/raw_data/releases/latest
Workshops: https://www.mothur.org/wiki/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 Introduction
4:19 Correcting p-values
7:09  Organizing code
9:04 Adding comparison bars with geom_segment
16:27 Adding stars with geom_text
19:04 Placing bars and stars to be closer to data
24:47 Testing code with different pooling threshold
26:01 Recap