Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

starting R in windows command terminal

Tags:

r

I cannot figure out how to start R in windows command terminal. I run cmd to open Command Prompt after I type R, rcmd, start R and try other possibilities I found around but I have an error: 'R' is not recognized as an internal or external command. I have R installed and I have a short-cut on my desktop and I am able to use it as RGui but I saw people use R in similar manner as python from command line.

I have 32-bit windows 7.

like image 541
Mus Avatar asked Feb 03 '13 20:02

Mus


People also ask

How do I start R from terminal?

Starting R If R has been installed properly, simply entering R on the command line of a terminal should start the program. In Windows, the program is typically specified as the action performed when clicking on an icon. You can also use this method on a *NIX system that has a window manager such as KDE.

How do I run an R file in windows command line?

You should use Rscript instead, assuming its in your PATH . E.g. Then Rscript is not in your PATH , so you need to add it. After you add Rscript to the path, in my case by adding the folder C:\Program Files\R\R-4.0.

How do I run an R command?

To run an R command, put the cursor on the line of the command and then click the Run button at the top of the file window. Or just press CTRL-Enter.

Can you run R script from command line?

Running R scripts from the command line can be a powerful way to: Automate your R scripts. Integrate R into production. Call R through other tools or systems.


1 Answers

If it's on your path type:

R.exe

To get it on your path:

Start/computer/systems properties/advanced system settings/Environment variables/in the lower box select path/Edit

then add location of R, mine is C:\R\R-2.15.1\bin but likely by default it's in program files.

This is what my variable value looks like:

C:\R\R-2.15.1\bin\i386;C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\gcc-4.6.3\bin;C:\Rtools\MinGW\bin;C:\R\bin;C:\Perl64\bin; C:\Program Files (x86)\MiKTeX 2.8\miktex\bin;C:\Program Files (x86)\HP SimplePass 2012\x64;C:\Program Files (x86)\HP SimplePass 2012\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\Services\IPT\;C:\Program Files (x86)\Pandoc\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\gs\gs9.06\bin;C:\Program Files (x86)\LibreOffice 3.5\URE\bin;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\; C:\Users\trinker\rubytools\bin

Then click OK three times. Now start a new command prompt and R.exe should be accessible.

like image 185
Tyler Rinker Avatar answered Oct 17 '22 00:10

Tyler Rinker