10

I need to launch R interactively (to be able to show a plot) from command prompt in win. Any idea how I can do this?

Thank you.

Bogdan_s02
  • 171
  • 1
  • 2
  • 6
  • 2
    Have you tried navigating (via the command line) to the directory in which R is installed and then typing `R.exe`? –  Aug 04 '11 at 10:56
  • Go to the command line. Type R. In Windows a standard install registers R in the registry, so it is runnable from everywhere in the directory system. On a sidenote, please read the [FAQ](http://stackoverflow.com/faq) on which questions should be asked here. Your question is off topic (and easily solved if you would have bothered to check [the R FAQ](http://cran.r-project.org/bin/windows/base/rw-FAQ.html) – Joris Meys Aug 04 '11 at 11:17
  • You can also type `Rgui` at the command prompt if you prefer. – Richie Cotton Aug 04 '11 at 11:17
  • 2
    If typing R at the cmd prompt doesn't work automagically, then you need to add R to your environment path. Here's a link complete with screenshots for Win 7: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx. Searching for "setting environment path windows XX" should find other tutorials as well. – Chase Aug 04 '11 at 11:19
  • @Chase, see mdsumner's answer below. :) – Roman Luštrik Aug 04 '11 at 11:27
  • Thanks for the replies but I would need to pass a script as a parameter when launching RGui and I don't know how to do that. – Bogdan_s02 Aug 04 '11 at 13:53

1 Answers1

8

Type the right version of this for your system:

C:\path\to\R\bin\R

That full path can be gotten from the installation location of R, or just from the R shortcut. On my machine by right-click - Properties (right click the shortcut within the task bar item on Win 7) and in Target on my machine is:

C:\inst\R\R\bin\x64\Rgui.exe

So, for me it is

C:\inst\R\R\bin\x64\R

or

C:\inst\R\R\bin\i386\R

or even more generally for current and older versions

C:\inst\R\R\bin\R

to start R.

I tend to always install R to this location, so I put my most used location (bin/x64) in my Path and I can type "R" from anywhere.

The Path on Windows is a semi-colon separated list of directories modified with Properties on My Computer under Advanced (System Settings), Environment Variables and within System or User variables.

mdsumner
  • 29,099
  • 6
  • 83
  • 91
  • Thank you for the answer. However, I need to run a script from the command line. I used Rscript so far which works fine as long as you don't need to plot anything or show graphics. I was not successful in passing my script as a paramter to RGui. – Bogdan_s02 Aug 04 '11 at 13:48
  • 1
    why would you want this? you can have interactive R run code with R -f code.R - but it will just do it and exit - unless you put in code that forcibly makes the user step in. Do you want to capture the graphics in file as well? I think you should get out of here and ask a new question – mdsumner Aug 04 '11 at 14:14
  • No. Basically I want the same behaviour as "RScript myScript.r param1 param2" but that would allow me to see graphics too (generated by the plot function inside the script). Also I would like to add that it's not just a plot, it is a gui that I usually run from RGui. – Bogdan_s02 Aug 04 '11 at 14:21
  • ask the question you really wanted answered, get out of here this is comment hell – mdsumner Aug 04 '11 at 14:25