Using ggplot2 to group x-axis discrete values into subgroups (CC133)

August 2, 2021 • PD Schloss • 1 min read

When we group sets of variables into subgroups on the x-axis we signal to our audience that they need to compare the values within the grouping. But how do we do this with ggplot2? In this episode of Code Club, Pat will show how you can great four (!) layers of subgroups by using the ggplot2 facet_wrap function. At the end, we’ll revisit our code and see how we can make it more DRY.

Pat will use functions from the mikropml R package and the facet_wrap function from ggplot2 as well as functions from dplyr and purrr in RStudio.

Code

You can browse the state of the repository at the

Installations

If you haven’t been following along, you can get caught up by doing the following: