I cannot run a R session from the command line by typing 'R', despite having
C:/Program Files/R
and
C:/Program Files/R/R-3.3.2/bin
in both 'Path' (System) and 'PATH' (User) environment variables (the latter directory is where the actual application is located, I was just trying everything by adding the former).
If I manually change the working directory to C:/Program Files/R/R-3.3.2/bin
and type R
, a session runs.
Any insight as to why this might be the case? Other programs such as Python 3 run fine, provided the the environment variable is set, why not with R?
This question is part of a larger problem where I am trying to get rpy2
working, but though successfully installed, none of it's basic functions are working, and I thought this maybe to do with a version of R
being installed at C:/Users/Anaconda2/R
(Because this dir was in Path). The R
application installed here would not work when opened, but was the directory returned when I typed R RHOME
into cmd - despite the fact this installation is not even functioning, and has apparently only existed since I installed rpy2
a couple of hours ago. I reasoned that rpy2
is trying to use the instance of R installed here rather than my normal one, thus causing the error when I call robjects.r
. But this still doesn't explain why I can't run R
from cmd. When using R.home(component = "home")
from inside a an R session (in RStudio or out of it), it returns my normal, working R
directory, at C:/PROGRA~1/R/R-33~1.2
. By moving the R file tree installed in Anaconda's directory to a somewhere not in Path, I hoped Windows would find the correct installation via Path - but instead I just get Failed to create process
.
My last guess was that Windows didn't like the space in "Program Files", but loads of variables in Path go through the same folder. Any ideas?
I am using:
Windows 10, R 3.3.2, Python 2.17.13
UPDATE, PERHAPS SOLVED:
On Josh O'Brien's recommendation (thanks!), I typed where R
into cmd, returning:
C:\Users\charl\Anaconda2\Scripts\R.exe
C:\Program Files\R\R-3.3.2\bin\R.exe
The first path is marginally different from the C:\Users\charl\Anaconda2\R
listed in my first post (both are in Path), and leads to a third R.exe
. It's outside the R file tree located in Anaconda, unlike my standard R installation, but seems to be dependent on it nonetheless. If I remove this R.exe
to another location (not in Path), Typing R
in cmd will run R from the desired directory, thus fixing the problem. R.home()
from inside that session confirms this.
My only remaining concern then; is whether this installation of R in Anaconda necessary for rpy2 or can I just delete it, fixing the original problem? It may just be my ignorance, but I was not conscious that installing rpy2 (I used the standard Windows installer rather than compiling manually) would install another instance of R - is it necessary for the package or just a default/option I failed to omit?