[R] Graphics device storable in a variable
Josh Tolley
eggyknap at gmail.com
Thu Nov 15 22:07:57 CET 2007
I'm using R embedded in PostgreSQL (via PL/R), and would like to use
it to create images. It works fine, except that I have to create every
image in a file (owned by and only readable by the PostgreSQL server),
and then use PostgreSQL to read from that file and return it to the
client. It would be much nicer if I could plot images into an R
variable (for instance, a matrix), and return that variable through
the PostgreSQL client. Leaving aside the details of returning the data
to PostgreSQL (which I realize are beyond the scope of this list), I
envision R code along the lines of the following:
# Create a png device, a handle to which is stored in myDevice
> myDevice <- png.variable(height = 1280, width = 1024, bg = "white")
# Plot some data into the current device
> plot(myX, myY, col="red")
# Finalize
> dev.off()
# Print out the contents of myDevice
> myDevice
...and the data would print out just like any other matrix or class or
whatever type myDevice actually is.
So my question is does such a thing already exist? I know about
piximage, but apparently I have to load image data from somewhere for
it to work; I can't use plot(), etc. to create the piximage data. GDD
would be a nice way to do it, because GD libraries are widely
available for use with other languages I might use with PostgreSQL and
PL/R (for instance, Perl would talk to PostgreSQL, call a PL/R
function to use R to return an image, which Perl would then process
further), but GDD requires temporary files as well, as far as I can
see. Thanks for any help anyone can offer.
-Josh / eggyknap
More information about the R-help
mailing list