Multiple versions of R installed - terminal launching wrong / different R from RStudio

I bet anaconda has just inserted its path at the front of your PATH variable and is overriding your newer 3.3.2 version at the terminal. If you want your 'RStudio' version to be the default version that pops up at your terminal when you type 'R', then you gotta modify your PATH. No biggie.

First, figure out which R version RStudio points to. Type the following into your RStudio console:

Sys.which("R")

I bet you'll see something like /usr/local/bin/R. So that's what you have to add to the front of your PATH (minus the '/R').

To confirm that anaconda has messed you up, open up your terminal and check out your PATH:

echo $PATH

You'll probably see /Users/YOURNAME/anaconda2/bin as the first entry in your PATH, and further down you'll see /usr/local/bin. We have to flip this order. There are a million ways to fix this. Here's the quick and dirty solution -- add the following to the bottom of your .bash_profile

export PATH="/usr/local/bin:$PATH"

And type R --version in your terminal to confirm that your default R has changed.

You might get fancy later with sed or awk if having two /usr/local/bin entries in your PATH annoys you (as it would me).

Tags:

Macos

R