Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding PATH to RStudio’s path

Tags:

r

rstudio

I am running RStudio on MacOS and need to use some custom command line tools like csvcut (part of csvkit) for a function that multiple people on our team will use on their machines.

If I run a system('pip install csvcut) (I am using this command as an example; normally, I’d run csvcut) from R in the terminal, it works (checks if the last version has been installed, etc.), just like if I do it from the command line terminal.

If I do the same thing from within RStudio:

> system('pip install csvkit')
sh: pip: command not found

If I do which pip in the terminal and copy-paste the address into RStudio, it works:

system('/anaconda3/anaconda/bin/pip install csvkit')
Requirement already satisfied (use --upgrade to upgrade): csvkit in /anaconda3/anaconda/lib/python3.4/site-packages
# etc.

^ that’s the output if I simply do system('pipinstall csvkit') from R in the terminal.

Unfortunately, I can’t even run which pip from within RStudio. (Also, I couldn’t automatically pip install csvkit for others’ machines, since it requires sudo access.) If there was a way to point RStudio to R’s path, that would be easier.

I found instructions on some website that said to create a .Renviron file and have a R_LIBS_USER=~/R/library line in it, but that didn’t help.

like image 837
Anarcho-Chossid Avatar asked Sep 04 '15 17:09

Anarcho-Chossid


1 Answers

Try adding this line to your .Renviron file:

PATH=/anaconda3/anaconda/bin:$PATH
like image 81
pcantalupo Avatar answered Oct 06 '22 00:10

pcantalupo