<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/engaging-the-tidyverse-clean-slate-protocol/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rud.is/b/2017/06/10/engaging-the-tidyverse-clean-slate-protocol/"> R – rud.is</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://i2.wp.com/rud.is/b/wp-content/uploads/2017/06/CSP.png?ssl=1" target="_blank"><img alt="" src="https://i2.wp.com/rud.is/b/wp-content/uploads/2017/06/CSP.png?resize=780%2C324&ssl=1" class="wp-image-6072" data-recalc-dims="1"></a></p>
<p>I caught the 0.7.0 release of <code>dplyr</code> on my home CRAN server early Friday morning and immediately set out to install it since I’m eager to finish up my <code>sergeant</code> package and get it on CRAN. “Tidyverse” upgrades aren’t trivial for me as I tinker quite a bit with the tidyverse and create packages that depend on various components. The <code>sergeant</code> package provides — amongst other things — a <code>dplyr</code> back-end for Apache Drill, so it has more tidyverse tendrils than other bits of code I maintain. </p>
<p>macOS binaries weren’t available yet (it generally takes 24-48 hrs for that) so I did an <code>install.packages(&quot;dplyr&quot;, type=&quot;source&quot;)</code> and was immediately hit with gcc 7 compilation errors. This seemed odd, but switching back to <code>clang</code> worked fine. </p>
<p>I, then, proceeded to run chunks in an Rmd I’m working on and hit “Encoding” errors on <code>mutate()</code> calls. Not having time to debug further I reverted to 0.5.0 of <code>dplyr</code> and went about my day and promised the tidyverse maintainers that I’d work on a reproducible example after work.</p>
<p>I made R data files from the data frames that were tossing errors and extracted &amp; tweaked a code snippet that consistently generated the error and created a rocker container on one of my linux boxes to validate that this was an error and a cross-platform one. The rocker container used a full fresh-from-source copy of the tidyverse including <code>dplyr</code> 0.7.0. The code worked and no error was generated, so I immediately suspected package rot on my main dev macOS box.</p>
<p>Now, my situation is complicated by an insanely hasty migration to macOS 10.13β1 (I refuse to use the Apple macOS catchy names anymore since the most recent one is just silly) and a move to the gcc 7 toolchain (initially prompted to both get <code>rJava</code> working nicely and reproduce some CRAN noted errors with some packages). Further complications were also created by many invocations of <code>install_github()</code> of various packages regularly overwriting bits of the tidyverse over the past few weeks since the R 3.4.0 release. In other words, the integrity of the “tidyverse” was in serious question on my system and it was time for the <a rel="nofollow" href="http://marvelcinematicuniverse.wikia.com/wiki/Clean_Slate_Protocol" target="_blank">Clean Slate Protocol</a>.</p>
<p>Rather than itemize package versions and surgically nipping and tucking, I opted to use <code>packrat</code> to get to my desired end-state of a full-integrity tidyverse install. There are many ways to do this. Feel free to “one-up” me and show your l33t method in the comments. This one will likely be accessible to most — if not all — R users.</p>
<p>I started a new RStudio project in a new session and told it to use <code>packrat</code>. In the new project console, I did <code>install.packages(&quot;tidyverse&quot;, type=&quot;source&quot;)</code> and let it go for many minutes. I, then, navigated to the packrat subdirectory where the 3.4 package binaries are housed (just follow the project <code>packrat</code> tree down to the R version directory) and moved all 51 packages (yes, 51 O_o) to the main R library path (which you can figure out by running <code>.libPaths()</code> in any non-<code>packrat</code>-maintained project).</p>
<p>After doing that, I fired up the originally failing Rmd and everything worked fine. <img alt="👍" src="https://s.w.org/images/core/emoji/2/72x72/1f44d.png" class="wp-smiley"></p>
<p>I don’t do the Clean Slate Protocol too often (we all get to for new R dot-releases) but it came in handy this time. If you run into errors when trying to get the new <code>dplyr</code> working, you may benefit from the Clean Slate Protocol as well.</p>
<p>If you haven’t seen the changes in 0.6.0/0.7.0 you should <a rel="nofollow" href="https://blog.rstudio.org/2017/04/13/dplyr-0-6-0-coming-soon/" target="_blank">check them out</a> and give it a go.</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://rud.is/b/2017/06/10/engaging-the-tidyverse-clean-slate-protocol/"> R – rud.is</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/6p3OBVNWkmE" height="1"></a></div>