From: Christophe Rhodes Date: Thu, 16 Sep 2010 20:01:25 +0000 (+0100) Subject: R implementation of the swank side of the (brand-new) slime-media contrib X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=commitdiff_plain;h=3cf3720a2c0a72d6f722a9b990891a27301fadcf R implementation of the swank side of the (brand-new) slime-media contrib Define a generic function to be used with the new makeReplResultFunction hook, with an implementation using png files for trellis objects. --- diff --git a/swank-media.R b/swank-media.R new file mode 100644 index 0000000..6e81dbb --- /dev/null +++ b/swank-media.R @@ -0,0 +1,19 @@ +makeMediaReplResult <- function(value) { + UseMethod("makeMediaReplResult") +} + +makeMediaReplResult.default <- function(value) { + makeReplResult(value) +} + +makeMediaReplResult.trellis <- function(value) { + filename <- tempfile("swank-media-") + png(filename, width=320, height=200) + print(value) + dev.off() + list(quote(`:write-image`), list(list(quote(`:type`), quote(png), + quote(`:file`), filename)), + deparse(value$call, nlines=1)) +} + +makeReplResultFunction <- makeMediaReplResult