[R] Graphics after invoking R from the command line

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Nov 28 18:34:44 CET 2007


On Wed, 28 Nov 2007, Mithun Jacob wrote:

> I've tried running graphics commands like plot by invoking R at the
> command line but the graphics window does not appear. I'm using
> R-2.6.0 on Windows XP and am using the cmd shell. Here's a sample
> session:
>
> R --slave --save --file=-
> x<-c(1,2,3,4)
> plot(x,x)
>
> This leads to nothing. I've found a way around it, but the graph
> window is frozen and commands to it have to be sent twice for the data
> to appear.
>
> R --slave --save --file=-
> x<-c(1,2,3,4)
> windows()
> plot(x,x)
> plot(x,x)
>
> Am I doing something wrong here? It would be nice if I could display a
> graphics window which isn't frozen.

So use R interactively, rather than in batch mode typing at stdin. (Using 
--file puts you into batch mode.) Only in interactive use does the event 
loop give time to windows such as the screen device, pagers, data frame 
viewers ....

I have no idea where you got the idea of 'R --slave --save --file=-' from: 
the way to use R 'at the command line' on Windows is to use Rterm.
'Rterm --slave --save' would do the same without the freezing, but most 
people do find prompts useful.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list