[R] Graphics device storable in a variable

Greg Snow Greg.Snow at intermountainmail.org
Thu Nov 15 22:32:34 CET 2007


You might try looking at the tkrplot package, it uses win.metafile and
captures the graphics device into a variable (which is then put into a
tk lable, but you could probably do something else with it).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Josh Tolley
> Sent: Thursday, November 15, 2007 2:08 PM
> To: r-help at r-project.org
> Subject: [R] Graphics device storable in a variable
> 
> 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
> 
> ______________________________________________
> R-help at 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.
> 



More information about the R-help mailing list