[R] Displaying Grahics to the X Window when calling R from command line
thomas.pologruto at credit-suisse.com
Wed Apr 16 15:11:22 CEST 2008
Thank you very much. Most appreciated.
Please follow the attached hyperlink to an important disclosure:
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Wednesday, April 16, 2008 8:52 AM
To: Pologruto, Thomas
Cc: r-help at r-project.org
Subject: RE: [R] Displaying Grahics to the X Window when calling R from
On Wed, 16 Apr 2008, Pologruto, Thomas wrote:
> Thank you for your response. I tried searching the archives but did
> not know that it was called X11() device.
> Can this be done in version 2.6.2 or do I need to have version 2.7.0
Flag --interactive is only in 2.7.0. There is no simple way to get
2.6.2 to accept input redirected from a script and run the event loop on
X11() depends. (One non-simple way is to write an alternative front
> running? Also, when you say wait in my script, I need to put a sleep
> or something in the script or else it will delete the plot when the
> script exits?
You need to ensure that the script does not exit, which will close the
device (not just delete the plot). Sys.sleep() may not be sufficiently
flexible -- one idea is to use locator() to get the viewer to click on
the plot when done with it.
Another route is to generate the plot as, say, a PNG file and launch a
separate viewer to show that via system(wait=FALSE).
> Thanks you again,
> Please follow the attached hyperlink to an important disclosure:
> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
> Sent: Wednesday, April 16, 2008 3:12 AM
> To: Pologruto, Thomas
> Cc: r-help at r-project.org
> Subject: Re: [R] Displaying Grahics to the X Window when calling R
> from command line
> The issue is that the X11() device is the default device only in
> interactive use, and further than the event loop is only run in
> interactive use.
> You need to
> 1) make use of R 2.7.0 RC
> 2) call R with R --vanilla --interactive
> 3) arrange for your script to wait for something so the plot remains
> This has come up before, so please search the archives for more
> On Tue, 15 Apr 2008, Pologruto, Thomas wrote:
>> I am running an R script from the command line by calling:
>>> R --vanilla < test.R
>> My terminal is part of the Xwin (Xterm) and there is a plot(1:10)
>> command in the test.R script.
>> This will not produce a grahic though.
> I think it does, on a PostScript or PDF file.
>> When I start R by calling R then
>> plotting from the R command in the same xterm, I do get a graphic
>> How do I create a xwin plot by calling R from the command line?
>> Any help is most appreciated. I have preprocessed the data in perl
>> and then feed it into my R script and want to see a plot on the
>> = ======== Please access the attached hyperlink for an important
>> electronic communications disclaimer:
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> 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
> ======== Please access the attached hyperlink for an important
> electronic communications disclaimer:
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
Please access the attached hyperlink for an important electronic communications disclaimer:
More information about the R-help