<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/wrapr-1-5-0-available-on-cran/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.win-vector.com/blog/2018/06/wrapr-1-5-0-available-on-cran/"> R – Win-Vector Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The <a rel="nofollow" href="https://www.r-project.org/" target="_blank"><code>R</code></a> package <a rel="nofollow" href="https://github.com/WinVector/wrapr" target="_blank">wrapr 1.5.0</a> is <a rel="nofollow" href="https://cran.r-project.org/package=wrapr" target="_blank">now available on CRAN</a>.</p>
<p><a rel="nofollow" href="https://github.com/WinVector/wrapr" target="_blank">wrapr</a> includes a lot of tools for writing better <code>R</code> code:</p>
<ul>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/let.html" target="_blank"><code>let()</code></a> (let block)</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/dot_arrow.html" target="_blank"><code>%.>%</code></a> (dot arrow pipe)</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/build_frame.html" target="_blank"><code>build_frame()</code></a> / <a rel="nofollow" href="https://winvector.github.io/wrapr/reference/draw_frame.html" target="_blank"><code>draw_frame()</code></a> ( <code>data.frame</code> builders and formatters )</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/qc.html" target="_blank"><code>qc()</code></a> (quoting concatenate)</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/named_map_builder.html" target="_blank"><code>:=</code></a> (named map builder)</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/coalesce.html" target="_blank"><code>%?%</code></a> (coalesce) <strong>NEW!</strong></li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/reduceexpand.html" target="_blank"><code>%.|%</code></a> (reduce/expand args) <strong>NEW!</strong></li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/uniques.html" target="_blank"><code>uniques()</code></a> (safe <code>unique()</code> replacement) <strong>NEW!</strong></li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/partition_tables.html" target="_blank"><code>partition_tables()</code></a> / <a rel="nofollow" href="https://winvector.github.io/wrapr/reference/execute_parallel.html" target="_blank"><code>execute_parallel()</code></a> <strong>NEW!</strong></li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/DebugFnW.html" target="_blank"><code>DebugFnW()</code></a> (function debug wrappers)</li>
<li><a rel="nofollow" href="https://winvector.github.io/wrapr/reference/defineLambda.html" target="_blank"><code>λ()</code></a> (anonymous function builder)</li>
</ul>
<p>I’ll be writing articles on a number of the new capabilities. For now I just leave you with the nifty operator <a rel="nofollow" href="https://en.wikipedia.org/wiki/Null_(SQL)#COALESCE" target="_blank">coalesce</a> notation.</p>
<p><span></span></p>
<p>
<p>Coalesce takes values from its arguments in left to right order taking the first non-<code>NA</code> value (if any available):</p>
<pre>
NA %?% 5 
# [1] 5

1 %?% 5 
# [1] 1

5 %?% NA
# [1] 5
</pre>
<p>For vectors each position is calculated independently, and scalars are re-cycled to vector sizes. This allows fairly complicated coalesce strategies (such as take from first two vectors if possible, else write in zero) to be expressed very succinctly:</p>
<pre>
vec1 &lt;- c(1, 2, NA, NA)
vec2 &lt;- c(10, NA, 20, NA) 
vec1 %?% vec2 %?% 0
# [1]  1  2 20  0
</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="http://www.win-vector.com/blog/2018/06/wrapr-1-5-0-available-on-cran/"> R – Win-Vector Blog</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/onPqL7GyW_8" height="1"></a></div>