Grouped stacked barchart for individuals using ggplot2 with geom_col and facet_grid (CC106)
Channel: Riffomonas Project
Date: 2021-05-19

If you've ever needed to create a stacked barchart for all of the individuals in your study, this episode of Code Club will show you how to do it with ggplot2's geom_col and facet_wrap/facet_grid functions. We'll group the individuals by one variable and we'll sort the individuals by the abundance of variable included in the stacked barchart. The episode will close with a critique of this type of figure.

Pat will use RStudio and the #geom_col and #facet_grid functions from the #ggplot2 package. The accompanying blog post can be found at https://www.riffomonas.org/code_club/2021-05-19-grouped-stacked-barchart.

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:34 Create stacked bar charts for each subject
11:27 Facet each disease status
12:28 Get width of facets to be proportional to N
13:35 Order subjects by abundance of Firmicutes
16:41 Stylize facet labels on bottom of plot
19:20 Critique