Christophe Weblog Wiki Code Publications Music
R implementation of the swank side of the (brand-new) slime-media contrib
authorChristophe Rhodes <csr21@cantab.net>
Thu, 16 Sep 2010 20:01:25 +0000 (21:01 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Thu, 16 Sep 2010 20:01:25 +0000 (21:01 +0100)
Define a generic function to be used with the new
makeReplResultFunction hook, with an implementation using png files
for trellis objects.

swank-media.R [new file with mode: 0644]

diff --git a/swank-media.R b/swank-media.R
new file mode 100644 (file)
index 0000000..6e81dbb
--- /dev/null
@@ -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