Using Different Versions of R
RStudio requires R version 2.11.1 or higher. Since R versions can be installed side-by-side on a system, RStudio needs to select which version of R to run against. The way this occurs varies between platforms—this article covers how version selection is handled on each platform.
On Windows, RStudio uses the system's current version of R by default. When R is installed on Windows it writes the version being installed to the Registry as the "current" version of R (the specific registry keys written are described here). This is the version of R which RStudio runs against by default.
You can override which version of R is used via General panel of the RStudio Options dialog. This dialog allows you to specify that RStudio should always bind to the default 32 or 64-bit version of R, or to specify a different version altogether:
Note that by holding down the Control key during the launch of RStudio you can cause the R version selection dialog to display at startup.
Mac OS X
R from CRAN
On Mac OS X if the only version of R you have installed is the standard R distribution from CRAN then RStudio will by default run against the current version of R.Framework. You can list all of the versions of R.Framework on your system and determine which one is considered the current one by executing the following command:
ls -l /Library/Frameworks/R.framework/Versions/
To change the current version of R.Framework you can either:
- Run the installer from CRAN for the R version you want to be current
- Use the RSwitch utility available at: http://r.research.att.com/
- Update the
R.framework/Versions/Currentdirectory alias directly using
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:
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
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
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.
On Linux, RStudio uses the version of R pointed to by the output of the following command:
which command performs a search for the R executable using the system PATH. RStudio will therefore by default bind to the same version that is run when R is executed from a terminal.
For versions of R installed by system package managers (e.g.
r-base on Debian or Ubuntu) this will be
/usr/bin/R. For versions of R installed from source this will typically (but not always) be
If RStudio is unable to locate R using
which R, it will fall back to scanning explicitly for the R script in the
If you want to override which version of R is used then you can set the
RSTUDIO_WHICH_R environment variable to the R executable that you want to run against. For example:
Not that in order for RStudio to see this environment variable when launched from the Ubuntu desktop Applications menu (as opposed to from a terminal) it must be defined in the
If you are running RStudio within a web browser then the version of R is determined by whatever version of R is running alongside RStudio Server. The version currently in use on the server can be be printed using the following command: