Donald, I was able to 'trick' R into writing plot data to a GNU Linux fifo. I had forgotten that the fifo will block until there is a process at either end (a writer and a reader):
At one terminal, create a fifo and set a program to catch output $ mkfifo Rfifo $ cat Rfifo At a second terminal $ R > postscript(file="Rfifo") > plot(0) > dev.off() -Matt On Wed, 2010-08-18 at 23:21 -0400, Matt Shotwell wrote: > Donald, > > At least for the PDF device (I know you asked about png, but I believe > they are similar), the answer no. Ultimately, this device calls the > standard C function fopen, and writes its data to the resulting file > stream. > > If you're using GNU Linux, you might trick R into writing to a fifo (a > named pipe, see 'man fifo'), or some other in-memory device, and read > from it with another program. My initial experiments with this, however, > were not successful. > > A better solution here, would be to have the various graphics devices > write to an R connection, as do most other R functions that input and > output data. In this way, we could write graphics data to a RAW > connection (rawConnection()), which is essentially a memory buffer. > > There are two obvious barriers to this: > 1. C level I/O routines (e.g. fprintf) are heavily integrated into the > graphics device code. Hence, accommodating R connections would require > significant changes. > 2. The graphics devices are mostly implemented in C, and there is (at > present) no interface to R connections at the C level. > > -Matt > > On Wed, 2010-08-18 at 21:49 -0400, Donald Paul Winston wrote: > > I need to write the output of a R plot to a Java OutputStream. It looks like > > R insists on sending it's output to a file. Is there anyway to get bytes > > directly from the output of a plot so I can write it with Java? Writing it > > to a file is too slow. > > > > Is there a parameter in the graphics device function png(..) that directs > > output to a variable in memory? > > > > x <- plot(.) would make sense. > -- Matthew S. Shotwell Graduate Student Division of Biostatistics and Epidemiology Medical University of South Carolina ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.