Running R from cmd on windows

I am trying to install rtools so that I can install another package (Google causalimpact), and the process indicated that I have a problem with my road environment for R.

Main problem

I can not start R from the cmd window.

The expected behavior should be displayed below and give a hint > :

 R version 3.1.1 (blah blah) ... Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. 

However, the actual result:

 'C:\Program' is not recognized as an internal or external command, operable program or batch file. 

Additional Information

I can run Rcmd and Rgui (everything except R ) from cmd without errors.

Where R outputs the output C:\Program Files\R\R-3.1.1\bin\x64\R.exe

Where Rcmd outputs the output C:\Program Files\R\R-3.1.1\bin\x64\Rcmd.exe

Where Rgui outputs the output C:\Program Files\R\R-3.1.1\bin\x64\Rgui.exe

Return the same paths as their corresponding EXE files.

This is clearly a problem with my global environment paths, but I cannot understand why this will lead to this error.

The paths look like (path R in the last line):

  c:\Rtools\bin c:\Rtools\gcc-4.6.3\bin C:\RBuildTools\3.1\bin C:\RBuildTools\3.1\gcc-4.6.3\bin c:\Rtools\bin c:\Rtools\gcc-4.6.3\bin C:\Python27\ C:\Python34\ C:\Python34\Scripts C:\Program Files (x86)\Intel\iCLS Client\ C:\Program Files\Intel\iCLS Client\ C:\windows\system32 C:\windows C:\windows\System32\Wbem C:\windows\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86 C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64 C:\Program Files\Intel\Intel(R) Management Engine Components\DAL C:\Program Files\Intel\Intel(R) Management Engine Components\IPT C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT C:\Program Files (x86)\QuickTime\QTSystem\ c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\ c:\Program Files\Microsoft SQL Server\100\Tools\Binn\ c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\ C:\strawberry\c\bin C:\strawberry\perl\site\bin C:\strawberry\perl\bin C:\Program Files\MiKTeX 2.9\miktex\bin\x64\ C:\Program Files\MiKTeX 2.9\miktex\bin\x64\ C:\Program Files\R\R-3.1.1\bin\x64 

I can run Python and Perl by simply typing any name into the CMD window, and as shown in Figure R, I cannot understand the above error.

If anyone has suggestions on how I can fix this error, I would be very grateful.

I did not ask a question of this nature here before all the editorial / pointers were also highly praised.

Raw path:

 PATH=C:\Program Files\R\R-3.1.1\bin\x64;C:\Program Files\R\R-3.1.1\bin\x64;c:\Rt ools\bin;c:\Rtools\gcc-4.6.3\bin;C:\RBuildTools\3.1\bin;C:\RBuildTools\3.1\gcc-4 .6.3\bin;c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;C:\Python27\;C:\Python34\;C:\Pyth on34\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iC LS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\Sy stem32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x 86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files\Intel\In tel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Manageme nt Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Componen ts\IPT;C:\Program Files (x86)\QuickTime\QTSystem\;c:\Program Files (x86)\Microso ft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microso ft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Bi nn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\strawberry\c\bi n;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program Files\MiKTeX 2.9 \miktex\bin\x64\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Users\Tariq.Muma n\AppData\Local\Pandoc\ 
+7
r
source share
4 answers

Try PATH=C:\Progra~1\R\R-3.1.1\bin\x64;... PATH variable to PATH=C:\Progra~1\R\R-3.1.1\bin\x64;...

It seems very likely that somehow your system parses spaces in Program Files as a trailing character in the path. Adjusting the definition, as indicated above, should make this impossible.

+7
source share

This is due to space. CMD understands: run "C: \ Program" with the argument "Files \ R \ R-3.1.1 \ bin \ x64 \ R.exe".

You must specify the entire line:

 "C:\Program Files\R\R-3.1.1\bin\x64\R.exe" 

... The trick is to drag the exec file into your command windows from your Windows Explorer and you will get the correct line to use.

+7
source share

Depending on how you set your PATH variable, you can use a character limit of 1024 . I tried to cut it and managed to bring it to 1152 characters, deleting long folder names and ending with \ characters. You might want to clear this and remove unused paths, or use some aliases to group your declaration paths.

One direct approach is to edit HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and edit the PATH value directly (then reboot to activate the new value).

Please note that although you can enter a very long path (up to a maximum environment variable length of 2048 or 32,768 bytes depending on the source), not all software will be able to read and process it correctly if it takes too long.

+1
source share

It is really easy. As for the JDK Path for Java, you set the R path as:

Path = "C: \ Program Files \ R \ R-3.4.2 \ bin \"

in the "Change system environment variables" section of the control panel.
Check if it works!

0
source share

All Articles