Displaying Diverging Data — Stacked?
Two ways of creating diverging stacked bar charts in R.
Published in
2 min readApr 1, 2022
There are at least seven ways of visualizing Likert Scale Data, and a trendy one is the diverging stacked bar chart. Let’s create it in R! All the code is in this GitHub repo.
- First, let’s create some dummy data.
The data looks like this:
Method one: “HH” package
You’ll get a figure like this. Not bad for a one-liner!
Method two: ggplot2
The data format required by ggplot2 is different:
- It should be long-format instead of wide-format (read more about the data format here)
- Some data points need to be negative to ensure the bar is centered at 0. Let’s make “Disagree” and “Strongly disagree” negative.
The dataframe looks like this:
You’ll get a figure like this:
Though more lines of code, ggplot2 offers more customizations, and you can change almost any aspect of this figure, but not with the HH package.
All the code above is in this GitHub repo.