From 03de6608402c91c474d0e5fb57569631ded3701a Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 9 Sep 2011 21:46:01 +0100 Subject: [PATCH] use a similar repl result method in swank-media.R for ggplot objects Should refactor (and provide width/height options) --- swank-media.R | 9 +++++++++ 1 file changed, 9 insertions(+) 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") -- 2.39.5