Controlling the version of R in your environment

The rapid pace of development for new packages and tools is both a blessing and a curse of the open source community. While great for testing new methodologies and taking advantage of cutting edge research, staying up to date at all times can quickly become a cumbersome chore.

A common question we get from new users is how to customize the version of R their projects use - either to a specific version or the most recent release. This is easy using Domino's custom compute environments, which allow you to specify which versions of which packages and programs you want your code and projects to run in. 

Depending on the version of Domino you're using, you may have access to our newest iteration of managed environments (V2 environments): while we recommend using them if you're able, we'll cover both below.


Regardless of the environment version you use, the basics of how environments are constructed remain the same: you'll need a base image (usually stored on, and some Dockerfile commands to install the additional programs or packages on top of that base. While you can execute additional commands in the form of pre- and post-setup scripts, we'll stick to the basics for this example.


R Upgrade

Next, we'll need the command to replace the current R instillation. You can either chose a specific release (a list of versions can be found on CRAN):


RUN apt-get update -y
RUN apt-get remove r-base-core -y && apt-get install r-base-core=3.3.1* -y

or just use the most recent release:

RUN apt-get update -y
RUN apt-get remove r-base-core -y && apt-get install r-base-core -y
Sometimes people want to install the latest release of R, at this moment it's 3.5.* which is still relatively new and has not yet been added to the main Ubuntu 14 and 16 package repositories. In order to get the 3.5, you need to add another reference to your source list.
For Ubuntu 14.04:
RUN add-apt-repository 'deb trusty-cran35/' && \
apt-get update && \
apt-get remove r-base-core -y && apt-get install r-base-core -y

For Ubuntu 16.04:

RUN add-apt-repository 'deb xenial-cran35/' && \
apt-get update && \
apt-get remove r-base-core -y && apt-get install r-base-core  -y

If you don't know what's the Ubuntu distro you're currently using type the following command into your terminal:

$ lsb_release -a

  Next, we'll show you how to put this into an environment and test it out. 


V2 Environments

You can create a custom V2 environment by going to Settings > Hardware & Environment > Compute Environment, selecting Manage V2 Environments, and then New Environment. You'll be prompted to name and describe the environment you're building, after which you'll be able to edit the definition. 


From here, you can either use your environment's base image or provide the link to a custom one.

Lastly, you'll add your custom RUN command for upgrading R to the Dockerfile instructions. Scroll to the bottom of the page and click Save. 

That's it! Your completed environment should look like this:


V2 environments will start building themselves as soon as you save the definition. To view the build logs after saving, click on the revisions tab, select the version of the environment you want to inspect (the most recent one) and click on the build logs tab. You'll have to refresh this page as the build progresses, but from here you're able to track the progress of the build and diagnose any errors. 


To test, navigate back to your project, ensure it's set to use the environment you just created, and start up an interactive RStudio session. At the top of the terminal, you should see R is running the version you specified.  


Additional Resources

If you run into any issues customizing your version of R or setting up custom environments, don't hesitate to reach out to For more details on what you can do with compute environments, check out the following resources:


Keywords: Updating R, Update R


Was this article helpful?
2 out of 2 found this helpful