<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/presenting-survey-data/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://scottishsnow.wordpress.com/2018/07/03/presenting-survey-data/"> R – scottishsnow</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>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 <a rel="nofollow" href="https://en.wikipedia.org/wiki/Likert_scale" target="_blank">likert</a>, I’ve tried a few ways to present these results. My current favourite is a stacked bar graph, ordered by agreement.</p>
<p>I’ve created an example of this using data from <a rel="nofollow" href="https://wingsoverscotland.com/scotland-versus-the-tories/" target="_blank">a political blog</a>. 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!</p>
<p>The question asked was:<em> In your personal experience/opinion, how would you rate the overall state of the following public services?</em></p>
<div data-shortcode="caption" class="wp-caption"><a rel="nofollow" href="https://scottishsnow.files.wordpress.com/2018/07/stacked_bar.png" target="_blank"><img data-orig-file="https://scottishsnow.files.wordpress.com/2018/07/stacked_bar.png?w=456" data-orig-size="1034,500" data-medium-file="https://scottishsnow.files.wordpress.com/2018/07/stacked_bar.png?w=456?w=300" data-attachment-id="1570" data-image-meta="{" data-image-description="" src="https://scottishsnow.files.wordpress.com/2018/07/stacked_bar.png?w=456" data-permalink="https://scottishsnow.wordpress.com/2018/07/03/presenting-survey-data/stacked_bar/" data-large-file="https://scottishsnow.files.wordpress.com/2018/07/stacked_bar.png?w=456?w=620" alt="stacked_bar" data-image-title="stacked_bar" sizes="(max-width: 620px) 100vw, 620px" data-comments-opened="1" class="wp-image-1570" data-recalc-dims="1"></a>
<p class="wp-caption-text">Results of a political poll take from: <a rel="nofollow" href="https://wingsoverscotland.com/scotland-versus-the-tories/" target="_blank">https://wingsoverscotland.com/scotland-versus-the-tories/</a></p>
</div>
<p>The code to produce this is below. Note the first mutate call is reordering the factor to ensure it appears correctly and not alphabetically.</p>
<pre>
library(tidyverse)
library(RColorBrewer)
df = read_csv(&quot;Downloads/voters.csv&quot;) %>%
   gather(Impression, Value, -Voters, -Area) %>%
   mutate(Impression=factor(Impression, levels=c(&quot;Good&quot;, &quot;Neither&quot;, &quot;Bad&quot;)))

ggplot(df, aes(Voters, Value, fill=Impression)) +
   geom_col(position=&quot;fill&quot;) +
   coord_flip() +
   facet_wrap(~Area) +
   scale_y_continuous(labels=scales::percent) +
   scale_fill_brewer(type=&quot;div&quot;) +
   labs(x=&quot;&quot;,
        y=&quot;Voters&quot;)
</pre>
<p>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.</p>
<div data-shortcode="caption" class="wp-caption"><a rel="nofollow" href="https://scottishsnow.files.wordpress.com/2018/07/heat_map.png" target="_blank"><img data-orig-file="https://scottishsnow.files.wordpress.com/2018/07/heat_map.png?w=456" data-orig-size="1034,343" data-medium-file="https://scottishsnow.files.wordpress.com/2018/07/heat_map.png?w=456?w=300" data-attachment-id="1571" data-image-meta="{" data-image-description="" src="https://scottishsnow.files.wordpress.com/2018/07/heat_map.png?w=456" data-permalink="https://scottishsnow.wordpress.com/2018/07/03/presenting-survey-data/heat_map/" data-large-file="https://scottishsnow.files.wordpress.com/2018/07/heat_map.png?w=456?w=620" alt="heat_map" data-image-title="heat_map" sizes="(max-width: 620px) 100vw, 620px" data-comments-opened="1" class="wp-image-1571" data-recalc-dims="1"></a>
<p class="wp-caption-text">Results of a political poll take from: <a rel="nofollow" href="https://wingsoverscotland.com/scotland-versus-the-tories/" target="_blank">https://wingsoverscotland.com/scotland-versus-the-tories/</a></p>
</div>
<pre>
ggplot(df, aes(Voters, Area, fill=Value)) +
   geom_raster() +
   facet_wrap(~Impression) +
   scale_fill_distiller(palette=&quot;Greens&quot;, direction=1) +
   labs(x=&quot;&quot;, y=&quot;&quot;, fill=&quot;% of\nvoters&quot;)
</pre>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://scottishsnow.wordpress.com/2018/07/03/presenting-survey-data/"> R – scottishsnow</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/usPu3rHGD3A" height="1"></a></div>