Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. 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)"

  2. Once homebrew is installed, use it to install R by running this command in Terminal:

    brew install r

  3. Check which versions of R are available to install by running:

    brew search r

  4. Choose the version of R you want to install (say version 3.5.3) and run:

    brew install r@3.5.3

  5. You can now use this version of R in Terminal by typing:

    R-3.5.3

  6. 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")