use a different r version temporarily in rstudio

I have installed an older R version using the source on a mac, but I am finding it difficult to get Rstudio to see this version. Is there an easy way to enable this

System Information:

  • RStudio Edition: (Desktop)
  • RStudio Version: 1.1.456
  • OS Version: OSX Mojave
  • R Version: 3.5.2 -> 3.4.1
  • sessionInfo():

Referred here from support.rstudio.com

Can you see your R version under this menu in global options?

Did this system variable Sys.getenv('R_HOME') correspond to the path to your desired R version?

I don't see the choose R sessions, my version details are

  • RStudio Edition: (Desktop)
  • RStudio Version: 1.1.456
  • OS Version: OSX Mojave
  • R Version: 3.5.2 -> 3.4.1

The R_HOME environment variable points to the right version but setting that variable changes nothing!

I'm also on Mojave RStudio Version 1.2.1194 and it does not have the Choose R Installation that the screenshot from a Windows version does.

Do I understand correctly that you have both 3.5.2 and 3.4.1, but you want to be able to have R downversion?

Have you tried using R Switch?

The binaries are available at https://r.research.att.com/

technocrat: you are correct, but I want to be able to switch between two different versions of R not downgrade permanently

mara: I have tried R switch but I had to install version 3.4.1 from source and Rswitch looks for the R version in /Library/Frameworks/ and is not able to find the source installation. I am also not finding a way to ask it to look in a different location.

This article talks about how to use a different version of R with RStudio Desktop:

The procedure is indeed system dependent. Here’s an excerpt of the section on R compiled from source on macOS:

R from source (including MacPorts and Homebrew)

When R is installed from CRAN on OS X the R executable is installed at /usr/bin/R . However, if R is installed directly from source or via a package manager like MacPorts or Homebrew, then the R executable is installed to either /usr/local/bin/R (Homebrew) or /opt/local/bin/R (MacPorts). In order to support these variations, RStudio scans for the R executable in the following sequence:

  1. /usr/bin/R
  2. /usr/local/bin/R
  3. /opt/local/bin/R

If RStudio is not able to locate R by scanning these locations, it will fall back to using whatever version of R is located at /Library/Frameworks/R.framework/ .

If you want to override the version of R selected by RStudio's default behavior then you can set the RSTUDIO_WHICH_R environment variable to the R executable that you want to run against. For example, to force RStudio to use the R executable located at /usr/local/bin :

export RSTUDIO_WHICH_R=/usr/local/bin/R

Note that in order for RStudio to see this environment variable it needs to be launched from a terminal where the variable has been set to the desired value and exported.

3 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.