From: Christophe Rhodes Date: Fri, 9 Sep 2011 20:46:01 +0000 (+0100) Subject: use a similar repl result method in swank-media.R for ggplot objects X-Git-Url: http://christophe.rhodes.io/gitweb/?a=commitdiff_plain;h=03de6608402c91c474d0e5fb57569631ded3701a;p=swankr.git use a similar repl result method in swank-media.R for ggplot objects Should refactor (and provide width/height options) --- diff --git a/swank-media.R b/swank-media.R index 686a636..01ea682 100644 --- a/swank-media.R +++ b/swank-media.R @@ -15,6 +15,15 @@ makeMediaReplResult.trellis <- function(value) { quote(`:file`), filename)), deparse(value$call, nlines=1)) } +makeMediaReplResult.ggplot <- 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)) +} makeMediaReplResult.numeric <- function(value) { string <- paste(deparse(value), sep="", collapse="\n")