<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/re-exporting-the-magrittr-pipe-operator/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://petermeissner.de/blog/2018/04/27/re-exporting-the-pipe/"> petermeissner</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>… or how I stoped worrying and wrote a blog post to remember it ad infinitum.</p>
<p>Magrittr’s pipe operator is one of those newish R-universe features that I<br>
really want to have around whenever I put some lines into an R-console.<br>
This is even <code>TRUE</code> when writing a package.</p>
<p>So the first thing I do is put <em>magrittr</em> into the <em>DESCRIPTION</em> file and add<br>
an <em>__imports.R</em> file to the packages <em>R/</em>-directory with the following lines:</p>
<div>
<div>
<pre><code><span>#' re-export magrittr pipe operator</span><span>
</span><span>#'</span><span>
</span><span>#' @importFrom magrittr %>%</span><span>
</span><span>#' @name %>%</span><span>
</span><span>#' @rdname pipe</span><span>
</span><span>#' @export</span><span>
</span><span>NULL</span><span>
</span></code></pre>
</div>
</div>
<p>These lines import and re-export the pipe operator (<code>%>%</code>) therewith allowing to<br>
use it within my package but also beeing able to use it interactively whenever<br>
the package is loaded.</p>
<p>Best of all these lines will also ensure passing all<br>
package checks (CRAN complient) and preventing any<br>
<em>“The following objects are masked from …”</em> messages.</p>
<p>Last but not least the file name <em>“__imports.R”</em> serves two purposes<br>
(1) making the it appear at the very beginning of an alphabetical sorted lists of<br>
file names and (2) second giving it a speaking name to inform – however<br>
reads the file name – that some R “Imports” are most likely happening inside.</p>
<p>Happy coding!</p>
<p>PS.: Those lines above require the usage of <code>roxygen2</code> as documentation framework.</p>
	<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://petermeissner.de/blog/2018/04/27/re-exporting-the-pipe/"> petermeissner</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 width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/PT0Gi3nTOu4" height="1"></a></div>