[R] plotting to stdout

Gene Selkov selkovjr at uchicago.edu
Fri Sep 7 18:36:49 CEST 2007


I have found two prior instances of this question in R-help, but I can't 
find the answer, and I'm giving up on mindless tinkering.

   http://tolstoy.newcastle.edu.au/R/help/03a/5994.html
   https://stat.ethz.ch/pipermail/r-help/2004-December/062259.html

I must be able to pipe the poltting commands to stdin and receive the plot 
on stdout, with errors written to stderr, should any occur.

Here's what I tried:

file test.r:
~~~~~~~~~~~~~~~~~~~~~~~~~~
postscript(stdout())
plot(0)
~~~~~~~~~~~~~~~~~~~~~~~~~~

This command:

    cat test.r | r --vanilla --slave

writes the output to a file named "1"

I have also tried:

   postscript(file=stdout())
   postscript(file=file("stdout"))

In the latter case, the output goes to the file named "3".

Other graphics devices do the same thing.

It is interesting that write.table() supports the file=stdout() idiom. If 
there is no official option to do this, I will appreciate a hint 
about the spot in the code where I can fix it.

Thanks,

--Gene

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> sessionInfo()
R version 2.5.1 (2007-06-27)
i386-apple-darwin8.10.1

locale:
C

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"



More information about the R-help mailing list