Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell RStudio to use R version from Anaconda

Tags:

macos

r

rstudio

I have installed anaconda and the conda package R on my mac os x yosemite. When I type

which R

in my terminal, I get the following output

/Users/giovannisoldi/anaconda/bin/R

so it is actually linking to the right version. However, when I open RStudio, I can see that the old version of R located in

/Library/Frameworks/R.framework/Versions/2.15/

is still used. I tried to link to the current version of R in Anaconda, with the following command:

ln -sfhv /Users/giovannisoldi/anaconda/bin/ /Library/Frameworks/R.framework/Versions/Current

However, by doing this RStudio complains that it can't locate R.

Is there a way to solve this issue?

like image 519
Giovanni Soldi Avatar asked Jan 13 '16 10:01

Giovanni Soldi


1 Answers

Here's how I did it:

which R
/Users/admin/anaconda/bin/R

In my ~/.bashrc (or your ~/.bash_profile) I put this:

export RSTUDIO_WHICH_R=/Users/admin/anaconda/bin/R 

Then source ~/.bashrc

(you now have to open RStudio from the terminal) finally, you can type

rstudio

or you can, again, edit your ~/.bashrc with alias rstudio='open -a RStudio .' and now the rstudio command will open RStudio in your current dir.

like image 99
snd Avatar answered Nov 17 '22 08:11

snd