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. Regards, Mithun
Prof Brian Ripley
2007-Nov-28 17:34 UTC
[R] Graphics after invoking R from the command line
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
On 11/28/2007 12:05 PM, 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.Do you really need to run R --slave? R is assuming it is running non-interactively, and won't leave any time free to handle events and update the window. If you just used "R" or "Rterm" as your command, you'd get an interactive command-line version of R running, and everything should work. Duncan Murdoch