Change version of R (r-base)
These instructions describe how to install a different version of R (r-base) on a cluster. You can check the default r-base version that each Databricks Runtime version is installed with in the System environment section of each Databricks Runtime release note.
List available r-base-core versions
To list the versions of r-base-core that can be installed and the version format:
Paste the following shell command in a notebook cell:
%sh add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial//' apt-get -y update apt-cache madison r-base-core
Run the cell.
For example, you can install version 3.3.3 by specifying 3.3.3-1xenial0
.
Install a specific R version
Paste the following shell command into a notebook cell. Set
<r-version>
to the R version to be installed. Set<init-script-path>
to a file path under/dbfs
where this init script will be saved.%sh R_VERSION='<r-version>' INIT_SCRIPT_PATH='<init-script-path>' mkdir -p $(dirname $INIT_SCRIPT_PATH) echo "set -e # Add the repository containing another version of R add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial//' apt-get -y update # Uninstall current R version apt-get remove -y r-base-core # Install another version of R apt-get install -y r-base-core=$R_VERSION # Must install Rserve to use Databricks notebook R -e \"install.packages('Rserve', repos='https://rforge.net/', type = 'source')\" R -e \"install.packages('hwriterPlus', repos='https://mran.revolutionanalytics.com/snapshot/2017-02-26')\"" > $INIT_SCRIPT_PATH
Run the notebook cell to save the init script to a file on DBFS.
Configure a cluster with the cluster-scoped init script. When specifying the init script path in the cluster creation UI, modify the format of the init script path to change
/dbfs
todbfs:/
. For example, if<init-script-path>
is set to/dbfs/examplepath/change-r-base.sh
, then in the cluster creation UI specify the init script pathdbfs:/examplepath/change-r-base.sh
.After the cluster starts up, verify that the desired R version is installed by running
%r R.version
in a notebook cell.