<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/fun-with-mms-april-3-2018/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://ibecav.github.io/mmms/"> Chuck Powell</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In this post we’re going to explore the <code>Chi Squared Goodness of Fit</code><br>
test using M&amp;M’s as our subject material. From there we’ll take a look<br>
at <code>simultaneous confidence intervals</code> a.k.a. <code>multiple comparisons</code>. On<br>
the <code>R</code> side of things we’ll make use of some old friends like <code>ggplot2</code><br>
and <code>dplyr</code> but we’ll also make use of two packages that were new to me<br>
<code>scimp</code> and <code>ggimage</code>. We’ll also make heavy use of the <code>kable</code> package<br>
to make our output tables look nicer.</p>
<h3>Background and credits</h3>
<p>See this <a rel="nofollow" href="http://blogs.sas.com/content/iml/2017/02/20/proportion-of-colors-mandms.html" target="_blank">blog post by Rick<br>
Wicklin</a><br>
for the full background story. This posting is simply an attempt to do<br>
the same sort of analysis in <code>R</code>. It is an expansion of work that <a rel="nofollow" href="https://rpubs.com/hrbrmstr/mms" target="_blank">Bob<br>
Rudis did on <code>RPubs</code>.</a></p>
<p>Let’s load the required R packages. See <a rel="nofollow" href="https://github.com/hrbrmstr/scimple" target="_blank">Bob Rudis’ Github<br>
pages</a> for more on scimple. Let’s<br>
take care of housekeeping and set up the right libraries.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>knitr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>kableExtra</span><span>)</span><span>
</span><span># devtools::install_github(&quot;hrbrmstr/scimple&quot;)</span><span>
</span><span>library</span><span>(</span><span>scimple</span><span>)</span><span> </span><span>library</span><span>(</span><span>hrbrthemes</span><span>)</span><span> </span><span># for scales</span><span>
</span><span># I had to install Image Magick first on my Mac as well as EBImage </span><span>
</span><span># https://bioconductor.org/packages/release/bioc/html/EBImage.html</span><span>
</span><span># install.packages(&quot;ggimage&quot;)</span><span>
</span><span>library</span><span>(</span><span>ggimage</span><span>)</span><span> </span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggplot2</span><span>)</span><span>
</span><span>options</span><span>(</span><span>knitr.table.format</span><span> </span><span>=</span><span> </span><span>&quot;html&quot;</span><span>)</span><span> </span><span>cap_src</span><span> </span><span>&lt;-</span><span> </span><span>&quot;Source: </span></code></pre></div></div>