0

I'm trying to use the call operator (&) to run an R script, and for some reason I am unable to direct to the right path on the D:\ drive, but it works fine on the C:\ drive (copied the R folder from D:\ to C:\ for testing).

https://i.stack.imgur.com/su8oc.jpg

The D:\ drive error appears like a space error, even though there are quotes around the string/variable.

Double spacing between "Program" and "Files", the call command reads correctly.

https://i.stack.imgur.com/bLinf.jpg

Ideally I would like to call to Rscript.exe on the D:\ drive, but I don't know why it's giving me an error - especially when the C:\ drive works fine and double spacing reads correctly.

Also worth noting "D:\Program Files (x86)" doesn't read correctly either, with similar symptoms.

Update: running

    gci -r d:\ -include rscript.exe | % fullname

returns:

D:\Program Files\R\R-3.2.3\bin\i386\Rscript.exe

D:\Program Files\R\R-3.2.3\bin\x64\Rscript.exe

D:\Program Files\R\R-3.2.3\bin\Rscript.exe

The last of which is what my variable $RscriptD is set to.

AlexL
  • 11
  • 6
  • Error messages look like `stderr` output from executable file converted to PowerShell `ErrorRecord`. – user4003407 Sep 03 '17 at 00:00
  • 1
    My bets are that it's not where you think it is; run `gci -r d:\ -include rscript.exe | % fullname` and post the results. – TessellatingHeckler Sep 03 '17 at 02:01
  • Did you try to set `"D:\Program Files\R\R-3.2.3\bin\i386\Rscript.exe"` or `"D:\Program Files\R\R-3.2.3\bin\x64\Rscript.exe"` to `$RscriptD`? Same result? – matt9 Sep 05 '17 at 14:10
  • @matt9 ".\i386\Rscript.exe" and ".\x64\Rscript.exe" work! Don't know what's up with the last link, but for my purposes using the other links will do. Do you know why ".\Rscript.exe" doesn't read properly? Thanks for everyone's help! – AlexL Sep 05 '17 at 20:32
  • @AlexL Rscript.exe cannot handle a whitespace well, I think. See the below answer. And if you have time, see [this](https://stackoverflow.com/questions/17845809/c-program-is-not-recognized-error) and try `D:\Progra~1` instead of `D:\Program Files`. – matt9 Sep 06 '17 at 12:03

1 Answers1

0

The first error message in your image is:

Rscript.exe : The term 'D:\Program' is not recognized as an internal or external command

This message means that the call operator (&) called Rscript.exe but Rscript.exe failed to do something by using 'D:\Program'.

I don't know exactly the details of internal process of Rscript.exe, however, I think Rscript.exe tried to run D:\Program Files\R\R-3.2.3\bin\i386\Rscript.exe or D:\Program Files\R\R-3.2.3\bin\x64\Rscript.exe but could not handle the whitespace of Program Files. Because the manual says:

Sub-architectures are also used on Windows, but by selecting executables within the appropriate bin directory, R_HOME/bin/i386 or R_HOME/bin/x64. For backwards compatibility there are executables R_HOME/bin/R.exe and R_HOME/bin/Rscript.exe: these will run an executable from one of the subdirectories, which one being taken first from the R_ARCH environment variable, then from the --arch command-line option and finally from the installation default (which is 32-bit for a combined 32/64 bit R installation).

According to this, I think it is better to call directly i386/Rscript.exe or x64/Rscript.exe rather than bin/Rscript.exe which is just for backwards compatibility.

matt9
  • 683
  • 5
  • 16