Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

Is there a way to have R plot to an in-memory object or connection, rather than a named file?

I would like to have a plotting server create many graphs without ever going to a file.

The Cairo package documents use of a connection, but it doesn't seem to work. What I would like to do is something like:

library(Cairo)
plot.to.var <- function(data) {
   tc = textConnection("output", "w")
   CairoPDF(tc)
   plot(data)
   dev.off()
   tc.close()
   output
}

When I do this, CairoPDF mentions a connection patch I can't find a reference to, that will allow me to do this, even though the documentation shows this working.

I have no particular desire to use Cairo, merely saw that the documentation mentioned this.

Any ideas?

share|improve this question

1 Answer

up vote 2 down vote accepted

I don't think so; R does not have binary memory buffers. Cairo feature you mentioned needs recompilation of both R and package; trying to do this with plain R does not throw errors, but nothing is written neither to textConnection nor socket.
So I think the best idea will be to use ramdisk; if you still want to try the patch, see this.

share|improve this answer
Thanks for the link! – Joe Sep 19 '10 at 10:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.