1 | initial version |
Install homebrew if it's not already installed on your Mac. Open Terminal and run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Once homebrew is installed, use it to install R by running this command in Terminal:
brew install r
Check which versions of R are available to install by running:
brew search r
Choose the version of R you want to install (say version 3.5.3) and run:
brew install r@3.5.3
You can now use this version of R in Terminal by typing:
R-3.5.3
To switch to a different version of R, run:
brew unlink r && brew link r@VERSION
Replace "VERSION" with the version number you want to use, such as:
brew unlink r && brew link r@3.6.3
This will switch to version 3.6.3 of R.
Note: You may need to install packages separately for each version of R you install. The packages you install for one version of R will not be available in other versions. To avoid conflicts, it's recommended to use separate R libraries for each version of R. You can create a library specific to a version of R by running this command in R:
.libPaths("/path/to/new/library")