Presenting survey data

By mikerspencer

stacked_bar

(This article was first published on R – scottishsnow, and kindly contributed to R-bloggers)

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="% ofnvoters")

To leave a comment for the author, please follow the link and comment on their blog: R – scottishsnow.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…

Source:: R News

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.