Ordering categories within ggplot2 facets
@drsimonj here to share my method for ordering categories within facets to create plots that look like this…
instead of like this…
Motivation: Tidy Text Mining in R
The motivation for this post comes from Tidy Text Mining in R by Julia Silge and David Robinson. It is a must read if text mining is something that interests you.
I noticed that Julia and David had left themselves a “TODO” in Chapter 5 that was “not easy to fix.” Not easy to fix? Could Julia Silge and David Robinson face challenges as the rest of us do?!
Shocking, I know.
Well, it was probably just a matter of time until they fixed it. Still, I thought it was an interesting challenge; gave it some thought, and wanted to share my solution.
They were using ggplot2 to create a bar plot with the following features:
- Facetted into separate panels
- One bar for each category (words in their case).
Continue reading →