Presenting survey data
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I work in a social science and economics department and a lot of our work is based on surveys of opinion. One question style we use a lot is likert, I’ve tried a few ways to present these results. My current favourite is a stacked bar graph, ordered by agreement.
I’ve created an example of this using data from a political blog. I was struggling to interpret the survey results in their table form, so spent a few minutes cleaning them in a spreadsheet and made the plots below. I don’t think the results entirely support the headline, but that’s news and politics for you!
The question asked was: In your personal experience/opinion, how would you rate the overall state of the following public services?

Results of a political poll take from: https://wingsoverscotland.com/scotland-versus-the-tories/
The code to produce this is below. Note the first mutate call is reordering the factor to ensure it appears correctly and not alphabetically.
library(tidyverse) library(RColorBrewer) df = read_csv("Downloads/voters.csv") %>% gather(Impression, Value, -Voters, -Area) %>% mutate(Impression=factor(Impression, levels=c("Good", "Neither", "Bad"))) ggplot(df, aes(Voters, Value, fill=Impression)) + geom_col(position="fill") + coord_flip() + facet_wrap(~Area) + scale_y_continuous(labels=scales::percent) + scale_fill_brewer(type="div") + labs(x="", y="Voters")
I’ve also experimented with displaying proportion data as heat maps, but feel there is too much work for the reader to interpret the results. Here’s an example, with code below.

Results of a political poll take from: https://wingsoverscotland.com/scotland-versus-the-tories/
ggplot(df, aes(Voters, Area, fill=Value)) + geom_raster() + facet_wrap(~Impression) + scale_fill_distiller(palette="Greens", direction=1) + labs(x="", y="", fill="% of\nvoters")
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.