Switching Between R Versions on Mac

Jun 26, 2020 Mac R

You can have multiple versions of R on your machine. To see all of them, go to the terminal and type:

ls -l /Library/Frameworks/R.framework/Versions/

View of ls

Notice that there is a symbolic link which equates the directory called 3.6 with the symbolic link called Current. Symbolic links are shortcults or aliases that point to files or directories.

RStudio uses the symbolic link called Current to know which version of R you want to run.

If you have multiple installed versions of R you can swap between them by doing the following steps. To start using version 4.0 do this:

  1. Go to the folder with all your versions of R cd /Library/Frameworks/R.framework/Versions/
  2. Remove the current symbolic link rm Current
  3. Make a symbolic link pointing at version of R ln -s 4.0 Current

If you wanto to switch back to 3.6 follow the same steps but change the symbolic link bac to 3.6:

  1. Go to the folder with all your versions of R cd /Library/Frameworks/R.framework/Versions/
  2. Remove the current symbolic link rm Current
  3. Make a symbolic link pointing at version of R ln -s 4.0 Current

PS If you are changing to a new version of R, check this post: https://www.r-bloggers.com/upgrade-r-without-losing-your-packages/