How to tell RStudio to use R version from Anaconda

2019-03-13 08:19发布

问题:

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?

回答1:

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.



标签: r macos rstudio