<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/multiple-versions-of-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rviews.rstudio.com/2018/03/21/multiple-versions-of-r/"> R Views</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img src="https://i2.wp.com/rviews.rstudio.com/post/2018-03-21-multiple-versions-r/pyramids.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p><em>Data scientists prefer using the latest R packages to analyze their data. To ensure a good user experience, you will need a recent version of R running on a modern operating system. If you run R on an production server – and especially if you use RStudio Connect – plan to support multiple versions of R side by side so that your code, reports, and apps remain stable over time. You can support multiple versions of R concurrently by building R from source. Plan to install a new version of R at least once per year on your servers.</em></p>
<div>
<h3>A solid foundation for R</h3>
<p>Administering R on the desktop is relatively easy, because desktops are designed for a single user at a specific time. Desktop users upgrade R versions and R packages as new software becomes available, leaving old versions and packages behind. Servers, on the other hand, are designed to support multiple people who want to access content across time. Servers are increasingly used for building <a rel="nofollow" href="https://rviews.rstudio.com/2017/12/20/rstudio-server-quick-start/" target="_blank">data science labs in R</a>, deploying R in production, and running R in the cloud. You may find that the same strategies you use to administer R on your desktop do not work as well on a server. In particular, upgrading your version of R must be handled differently.</p>
<p>If you upgrade R on your server as you do on your desktop, you could easily break some apps and disrupt your teams. Administrators should exercise caution when <a rel="nofollow" href="https://shiny.rstudio.com/articles/upgrade-R.html" target="_blank">upgrading to a new version of R</a> on a Linux server. Consider the following situations:</p>
<ul>
<li>You are hosting apps on RStudio Connect and Shiny Server for more than a year. When you upgrade R, you break many of your older apps.</li>
<li>Your team is developing code on a shared instance of RStudio Server. When you upgrade R, you disrupt people’s work and break their code.</li>
</ul>
<p>Instead of upgrading your existing version of R, a better solution to these problems is to run multiple versions of R side by side. This strategy preserves past versions of R so you can <a rel="nofollow" href="http://docs.rstudio.com/ide/server-pro/r-versions.html#managing-upgrades-of-r" target="_blank">manage upgrades</a> and keep your code, apps, and reports stable over time.</p>
</div>
<div>
<h3>Building R from source</h3>
<p>The best way to run multiple versions of R side by side is to build R from source. If you are running R on a Linux server – and particularly in the enterprise – you should always build R from source, because it will help you:</p>
<ol>
<li>Run multiple versions of R side by side</li>
<li>Guarantee that R will work on your unique server configuration</li>
<li>Potentially speed up certain low-level computations used by R</li>
<li>Build technical expertise that will help you administer R at scale</li>
</ol>
<p>Most enterprise IT departments will be comfortable building software from source. If you have never built R from source, it is very straightforward. First, you need the build dependencies for R. If you’ve already installed R from a binary source like CRAN or EPEL, you may already have these dependencies installed; otherwise, you can run <code>sudo yum-builddep R</code> on RedHat or <code>sudo apt-get build-dep r-base</code> on Ubuntu. Second, you should obtain and unpack the <a rel="nofollow" href="https://cran.rstudio.com/src/base/" target="_blank">source tarball</a> for the version of R you want to install from CRAN. Third, from within the extracted source directory, build R from source using <code>configure</code>, <code>make</code>, and <code>make install</code> commands. For example:</p>
<pre><code># BUILD R FROM SOURCE ON REDHAT LINUX
# R-3.4.3

# Install Linux dependencies
$ sudo yum-builddep R

# Download and extract source code
$ wget https://cran.r-project.org/src/base/R-3/R-3.4.3.tar.gz
$ tar -xzvf R-3.4.3.tar.gz
$ cd R-3.4.3

# Build R from source
$ ./configure --prefix=/opt/R/$(cat VERSION) --enable-R-shlib --with-blas --with-lapack
$ make
$ sudo make install</code></pre>
<p>This script installs R version 3.4.3 into <code>/opt/R/3.4.3</code>, but you can install R into any of the <a rel="nofollow" href="http://docs.rstudio.com/ide/server-pro/r-versions.html#recommended-installation-directories" target="_blank">recommended directories</a>. The <code>--enable-R-shlib</code> option is required to make the shared libraries known to RStudio. The <code>--with-blas</code> and <code>--with-lapack</code> options are not required, but are commonly included. These options install the system <a rel="nofollow" href="http://www.netlib.org/blas/#_presentation" target="_blank">BLAS</a> and <a rel="nofollow" href="http://www.netlib.org/lapack/#_presentation" target="_blank">LAPACK</a> libraries, which are used to speed up certain low-level math computations (e.g., multiplying and inverting matrices). These libraries will not speed up R itself, but can significantly speed up the underlying code execution.</p>
<p>If you run into problems installing R from source, you can always remove the installation directory and start over. However, once the installation succeeds, you should never move the installation directory – in other words, always install into the final destination directory. If you run into problems with dependencies, make sure you are able to identify and install all of the required Linux libraries (e.g., the X11 library is commonly overlooked). Building R from source will be much easier with a modern operating system that is connected to the Internet.</p>
<p>For further details about building R from source, see the <a rel="nofollow" href="http://docs.rstudio.com/ide/server-pro/r-versions.html#building-additional-versions-from-source" target="_blank">RStudio Server Admin Guide</a>.</p>
</div>
<div>
<h3>RStudio professional products</h3>
<p>RStudio professional products automatically support multiple versions of R and provide <a rel="nofollow" href="http://docs.rstudio.com/ide/server-pro/r-versions.html#overview-3" target="_blank">additional features</a>, such as having administrators control access to multiple versions, or allowing users to choose for themselves. RStudio Connect automatically provides <a rel="nofollow" href="http://docs.rstudio.com/connect/admin/r.html#r-version-matching" target="_blank">R version matching</a>. Running multiple versions of R side by side with RStudio Connect will ensure that your content persists over time.</p>
</div>
<div>
<h3>References</h3>
<ul>
<li><a rel="nofollow" href="https://support.rstudio.com/hc/en-us/articles/215488098-Installing-multiple-versions-of-R-on-Linux" target="_blank">Installing multiple versions of R on Linux</a></li>
<li><a rel="nofollow" href="https://shiny.rstudio.com/articles/upgrade-R.html" target="_blank">Upgrading to a new version of R</a></li>
<li><a rel="nofollow" href="https://support.rstudio.com/hc/en-us/articles/212364537-Multiple-Versions-of-R-in-RStudio-Server-Pro" target="_blank">Multiple versions of R with RStudio Server Pro</a></li>
<li><a rel="nofollow" href="http://docs.rstudio.com/shiny-server/#r_path" target="_blank">Multiple versions of R with Shiny Server Pro</a></li>
<li><a rel="nofollow" href="http://docs.rstudio.com/connect/admin/r.html#upgrading-r" target="_blank">Multiple versions of R with RStudio Connect</a></li>
</ul>
</div>
<p> </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://rviews.rstudio.com/2018/03/21/multiple-versions-of-r/"> R Views</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/Vc2Bh4nj2oU" height="1"></a></div>