<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/tutorial-using-seplyr-to-program-over-dplyr/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2017/07/tutorial-using-seplyr-to-program-over-dplyr/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://github.com/WinVector/seplyr" target="_blank"><code>seplyr</code></a> is an <a rel="nofollow" href="https://www.r-project.org/" target="_blank"><code>R</code></a> package that makes it easy to program over <a rel="nofollow" href="https://cran.r-project.org/package=dplyr" target="_blank"><code>dplyr</code> <code>0.7.*</code></a>.</p>
<p>To illustrate this we will work an example.</p>
<p><span></span></p>
<p>Suppose you had worked out a <code>dplyr</code> pipeline that performed an analysis you were interested in. For an example we could take something similar to one of the examples from the <a rel="nofollow" href="https://blog.rstudio.com/2017/06/13/dplyr-0-7-0/" target="_blank"><code>dplyr</code> <code>0.7.0</code> announcement</a>.</p>
<div>
<pre><code><span>suppressPackageStartupMessages</span>(<span>library</span>(<span>&quot;dplyr&quot;</span>))
<span>packageVersion</span>(<span>&quot;dplyr&quot;</span>)</code></pre>
</div>
<pre><code>## [1] '0.7.2'</code></pre>
<div>
<pre><code><span>cat</span>(<span>colnames</span>(starwars), <span>sep=</span><span>'</span><span>\n</span><span>'</span>)</code></pre>
</div>
<pre><code>## name
## height
## mass
## hair_color
## skin_color
## eye_color
## birth_year
## gender
## homeworld
## species
## films
## vehicles
## starships</code></pre>
<div>
<pre><code>starwars %>%
<span> </span><span>group_by</span>(homeworld) %>%
<span> </span><span>summarise</span>(<span>mean_height =</span> 
              <span>mean</span>(height, <span>na.rm =</span> <span>TRUE</span>),
            <span>mean_mass =</span> 
              <span>mean</span>(mass, <span>na.rm =</span> <span>TRUE</span>),
            <span>count =</span> <span>n</span>())</code></pre>
</div>
<pre><code>## # A tibble: 49 x 4
##         homeworld mean_height mean_mass count
##             </code></pre>