<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/harry-potter-and-competition-results-with-comperes/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.questionflow.org/2018/05/09/harry-potter-and-competition-results-with-comperes/"> QuestionFlow </a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p> Exploration of Harry Potter Books Survey results with help of my new comperes package.</p>
<div>
<h1>Prologue</h1>
<p>About a month ago I decided to add interesting data set to my almost finished (hopefully, soon to be on CRAN) <a rel="nofollow" href="https://github.com/echasnovski/comperes" target="_blank">comperes</a> package. Data should represent results of some not ordinary competition. After some thought I picked a “competition” between Harry Potter books with a goal eventually to rate them from worst to best. After a series of events I ended up creating data myself. You can read more about that in my <a rel="nofollow" href="http://www.questionflow.org/2018/04/09/struggle-with-harry-potter-data/" target="_blank">previous post</a>.</p>
<p>Post and survey in general were popularized mostly among R users with <a rel="nofollow" href="https://www.r-bloggers.com/" target="_blank">R-bloggers</a> (which gave me ~53 respondents), <a rel="nofollow" href="https://twitter.com/" target="_blank">Twitter</a> (which added the rest) and <a rel="nofollow" href="https://www.reddit.com/r/rstats/" target="_blank">Reddit</a> (which added ~0 people as post was deleted soon after publication). Survey managed to attract 182 respondents. I want to greatly thank all people who took their time to take part in and spread a word about my survey. Special thanks goes to <a rel="nofollow" href="https://twitter.com/dataandme" target="_blank">Mara Averick</a> who started a Twitter wave.</p>
<p>This post has two goals:</p>
<ul>
<li>Present and explore results of the survey.</li>
<li>Demonstrate basic functionality of <code>comperes</code> package. To learn more go to its <a rel="nofollow" href="https://github.com/echasnovski/comperes#comperes" target="_blank">README</a> and vignettes.</li>
</ul>
</div>
<div>
<h1>Overview</h1>
<p>Survey results can be obtained by installing development version of <code>comperes</code> package from GitHub. They are present as package data named <code>hp_survey</code>.</p>
<p>This post will cover the following topics:</p>
<ul>
<li><strong>Exploration</strong> of survey results (most important being <strong>Book scores</strong> section).</li>
<li>Description of <code>comperes</code> <strong>competition results</strong> formats with conversion <code>hp_survey</code> to one of them.</li>
<li><strong>Head-to-Head</strong> “performance” of books against each other.</li>
</ul>
<p>We will need the following setup:</p>
<pre><code>library(dplyr)
library(tidyr)
library(rlang)
library(stringr)
library(ggplot2)
library(comperes)

set.seed(201805)

theme_set(theme_bw())

# Authenticity palette
hp_pal &lt;- c(Gryff = &quot;#D02037&quot;, Huffl = &quot;#F0C346&quot;,
            Raven = &quot;#2450A8&quot;, Raven_light = &quot;#0088FF&quot;,
            Slyth = &quot;#09774A&quot;)

# For less noisy bar charts
theme_bar &lt;- function() {
  list(theme(panel.grid.major.x = element_blank(),
             panel.grid.minor.x = element_blank()))
}</code></pre>
</div>
<div>
<h1>Exploration</h1>
<div>
<h2>Data preparation</h2>
<p><code>hp_suvery</code> is a <a rel="nofollow" href="http://tibble.tidyverse.org/" target="_blank">tibble</a> (enhanced data frame) and has the following columns:</p>
<ul>
<li><strong>person</strong> </ul></div></div>