0

I'm on Windows 10. In C:\Program Files\R\ , the only directory is for R 3.4.0 and I just uninstalled all R versions and then re-installed only 3.4.0. When I open RStudio, it uses 3.4.0. However, when I run R.exe or RScript.exe from Windows PowerShell, it uses 3.3.2. At one point, I had 3.3.2 installed, but I thought I removed it!

RStudio already uses 3.4.0 as it is, so how can I get R.exe and RScript.exe to use 3.4.0?

The main issue is that because of this, R.exe and RScript.exe do not recognize libraries that I have installed in 3.4.0.

Thank you.

BenH
  • 8,967
  • 1
  • 15
  • 31
rybj
  • 1
  • 1
  • What does `system("PATH")` say? Is 3.3.2 in there? – Roman Luštrik May 25 '17 at 20:46
  • 2
    When R 3.3.2 launches, run `R.home()` to see where it's installed. – MrFlick May 25 '17 at 20:46
  • @MrFlick The output made me snicker. It says: "C:/Users/name/AppData/Local/Continuum/Anaconda3/R" So it's using the R that's installed for Jupyter. – rybj May 25 '17 at 20:51
  • @RomanLuštrik Is that supposed to be run from R or PowerShell? – rybj May 25 '17 at 20:54
  • So I suppose from this point, I can either upgrade the version that Jupyter is using or just make R.exe and RScript.exe point to a different path. I'd prefer the latter--is there a way for me to do that? – rybj May 25 '17 at 20:57
  • I think Roman meant `Sys.getenv("PATH")` from within R. But it does depend on your PATH environment variable. Powershell will stop looking for R after it finds the first one in your PATH. [maybe this question](https://stackoverflow.com/questions/714877/setting-windows-powershell-path-variable) can help you change your path if you want to find the other R first, but then that might mess up Jupyter. – MrFlick May 25 '17 at 20:57
  • @MrFlick bah, I assumed since `PATH` works from the command line that it will also work through R... Of course, I was referring to the system PATH which is available through `Sys.getenv`. – Roman Luštrik May 25 '17 at 21:01
  • Since the old `R.exe` is located in a `PATH` folder, in PowerShell you will need to type out the full location of `R.exe` so that you are sure to call the correct one. e.g. `& "C:\Program Files\R\R.exe"` – BenH May 25 '17 at 21:07
  • @MrFlick hmm, I'm getting error messages when I try the $Env:Path syntax in that thread. – rybj May 25 '17 at 21:07
  • @BenH Yes, but I'd prefer to be able to just say RScript.exe because when I tried that approach that you suggested, it set the R working directory to the directory that R was in instead of the directory of the script I was running. I'd prefer not to simply include a setwd command in the script because it needs to be passed on to other computers. – rybj May 25 '17 at 21:10
  • Okay, so I understand that I need to put the path I want at the top of the powershell PATH file. I've never worked with a PATH file before, and I'm somewhat confused about this. How do I find where my PATH file is located? – rybj May 25 '17 at 21:11
  • 1
    PATH isn't a file but an environmental variable. Control Panel -> System -> Advanced System Settings -> Environment Variables – BenH May 25 '17 at 21:12
  • @BenH Okay, I just went through that sequence and I added "C:\Program Files\R" (which only contains 3.4.0) to the path variable and moved it all the way to the top. However, R.exe still opens up 3.3.2. Am I missing something? – rybj May 25 '17 at 21:23

0 Answers0