<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/please-inspect-your-dplyrdatabase-code/"></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/12/please-inspect-your-dplyrdatabase-code/"> 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 note to <code>dplyr</code> with database users: you may benefit from inspecting/re-factoring your code to eliminate value re-use inside <code>dplyr::mutate()</code> statements.<span></span></p>
<p>
<p>If you are using the <a rel="nofollow" href="https://www.r-project.org/" target="_blank"><code>R</code></a> <a rel="nofollow" href="https://cran.r-project.org/package=dplyr" target="_blank"><code>dplyr</code></a> package with a database or with <code>Apache Spark</code>: I respectfully advise you inspect your code to ensure you are not using <em>any</em> values created inside a <code>dplyr::mutate()</code> statement inside the <em>same</em> <code>dplyr::mutate()</code> statement. This <a rel="nofollow" href="http://www.win-vector.com/blog/2017/09/my-advice-on-dplyrmutate/" target="_blank">has been my coding advice</a> for some time, and it is a simple and safe re-factoring to break up such statements into safer sequences (simply by introducing more <code>dplyr::mutate()</code>s).</p>
<p>I have since encountered a <a rel="nofollow" href="https://github.com/WinVector/Examples/blob/master/dplyr/Dependencies.md" target="_blank">non-signaling (or silent) result corruption version of the issue</a>. We are now advising code inspection as we now have confirmation that not seeing a thrown error is <em>not</em> a reliable indication of correct execution and correct results.</p>
<p>To keep things in proportion: if you are not writing multi-assignment mutates on a <code>dplyr</code> database-backed system you <em>can’t</em> run into the problem (though, for performance, multi-statement mutates are preferred over database sources such as <code>Apache Spark</code>).</p>
<p>The issue has been reported to the <code>dplyr</code> team. And I presume a fix is in the works. However, one does not want to be distributing incorrect results in the interim. This is the advice I have been giving private clients. After some thought I have come to feel it would be unfair to withhold such advice from the larger <code>R</code> community. This is not meant to make <code>dplyr</code> look bad, but to try and help prevent both <code>dplyr</code> and <code>dplyr</code> users from unnecessarily looking bad.</p>
<p>To be clear: I am a proponent of <code>dplyr</code> plus database development (which is why I ran into this). Also, I am not affiliated with <code>RStudio</code> or affiliated with the <code>dplyr</code> development team.</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="http://www.win-vector.com/blog/2017/12/please-inspect-your-dplyrdatabase-code/"> 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/tgsq5nzFwoY" height="1"></a></div>