# Making barplot-esque “stacked pie charts” using ggplot2 and R. These are “stacked pie charts” that I made using ggplot2 in R. Ideal for data like grade distributions that you might want to compare between two or more groups that sum to 1 within a group (or could sum to one if converted to proportions of count data).

Hello fellow R nerds!

One of the things I intend to do with this blog from time to time is share tricks I have learned in R. I recently became entangled with an interesting data set, and I was struggling to display the results from this data set effectively. I think I’ve cooked up some code to solve this problem that might be useful for you.

In essence, the data set included two types of data: 1. grades students got in a given course and 2. responses those same students provided on a questionaire. We wanted to see if students who provided certain responses to certain questions were more likely to get a higher grade.

We found out that, yes, there were some significant relationships here. Cool! But how best to graph these data?? See, normally, I would say these data should be plotted as grouped boxplots, one boxplot per question response group (making these is a blog post unto itself!). If that didn’t look impressive, maybe I’d say they could be graphed as scatterplots, with responses represented “numerically” on the X axis (1, 2, and 3). The problem with these plans is that the number of combinations in the data is small-—there’re only so many grades students can get and only so many responses to a given question. So, boxplots for the three response groups to a given question basically look the same, and the scatterplots suffered from a lot of overplotting, even with jittering of points. Thus, the boxplots and scatterplots I made for these data were…unimpressive let’s say.

Instead, I thought: What if I could show the grade distributions for all students who gave each response to the survey question? In essence, I was imagining “pie charts” for each survey response, but in the form of bars so that bar sizes (proportions) could be compared more easily. I’ve provided all the code necessary to produce charts like these in this attached Word document I created using R Markdown. Post any questions you might have in the comments!