Ask Your Question
3

How can I install and use multiple versions of R on a Mac?

asked 2023-07-19 09:18:47 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2023-07-19 09:41:01 +0000

scrum gravatar image
  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/Homeb…)"

  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")
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-19 09:18:47 +0000

Seen: 12 times

Last updated: Jul 19 '23