19 May 2022

Multiple R-Versions on OSX

  1. Installing an old version of R
  2. Toggling between different versions of R

I've recently ran into the issue of handling multiple R-versions on my Mac. I would have to switch between version 3.6.3 and version 4.1. I am on the Macbook Pro 14 inch from 2021.

Installing an old version of R

I was able to find the binaries for 3.6.3 on CRAN. However, I could not install it on Monterey. OSX does not easily permit you to install packages that they cannot check for 'malicious software'. Go to System Preferences > Security & Privacy and you will see the option to install the package anyway.

Toggling between different versions of R

To reiterate, I have just installed R 3.6.3 when I've already had R 4.1 installed. The package installer from CRAN updated my current version of R to 3.6.3. From what I have gathered, the current version folder for R is a symlink to the specific version folder. /Library/Frameworks/R.framework/Versions is the path where you will find all the R versions installed on your system along with a symlink Current folder. Setting the R version you wish to use is as simple as updating the symlink.

cd /Library/Frameworks/R.framework/Versions
unlink Current
ln -s 4.1 Current

The above code snippet will update your current R version to 4.1 again. RStudio will use this version when you open it. You can check the current version by running ls -l Current to see which version folder the symlink points to.

Tags: R