org-babel: capture graphical output from R
commit8b52bf09e0644cc5b6ea85e5248403fcd562f4f3
authorDan Davison <davison@stats.ox.ac.uk>
Tue, 20 Oct 2009 01:00:24 +0000 (19 21:00 -0400)
committerDan Davison <davison@stats.ox.ac.uk>
Tue, 20 Oct 2009 01:44:28 +0000 (19 21:44 -0400)
treeade56261725fe9a8482c44f286addce4ab700bc7
parent4d374b27d2f6cb26238aeefabb01383bf16ecdee
org-babel: capture graphical output from R

If a [:file filename.ext] header arg is provided, then all graphical
output from the source block is captured on disk, and output of the
source block is a link to the resulting file, as with the
graphics-only languages such as gnuplot, ditaa, dot, asymptote. An
attempt is made to find a graphics device corresponding to the file
extension (currently .png, .jpg, .jpeg, .tiff, .bmp, .pdf, .ps,
.postscript are recognised); if that fails, png format output is
created.

Additionally, values for several arguments to the R graphics
device can be passed using header args:

:width :height :bg :units :pointsize
:antialias :quality :compression :res :type
:family :title :fonts :version :paper :encoding
:pagecentre :colormodel :useDingbats :horizontal

Arguments to the R graphics device that are not supported as header
args can be passed as a string in R argument syntax, using the header
arg :R-dev-args

An example block is (although both bg and fg can be passed directly as
header args)

\#+begin_src R :file z.pdf :width 8 :height 8 :R-dev-args bg="olivedrab", fg="hotpink"
  plot(matrix(rnorm(100), ncol=2), type="l")
\#+end_src
contrib/babel/lisp/langs/org-babel-R.el