User manual

Chapter 11: Other ESS features and tools 61
11.11 Interaction with Org mode
Org-mode (http://orgmode.org) now supports reproducible research and literate
programming in many languages (including R) see chapter 14 of the Org manual
(http://orgmode.org/org.html#Working-With-Source-Code). For ESS users, this
offers a document-based work environment within which to embed ESS usage. R code lives
in code blocks of an Org document, from which it can be edited in ess-mode, evaluated,
extracted ("tangled") to pure code files. The code can also be exported ("woven") with
the surrounding text to several formats including HTML and LaTeX. Results of evaluation
including figures can be captured in the Org document, and data can be passed from the
Org document (e.g. from a table) to the ESS R process. (This section contributed by Dan
Davison and Eric Schulte.)
11.12 Support for Sweave in ESS and AUCTeX
ESS provides support for writing and processing Sweave (http://www.statistik.lmu.de/~leisch/Sweave),
building up on Emacs’ ess-noweb-mode for literate programming. When working on an
Sweave document, the following key bindings are available:
[Command]ess-swv-weave choose
M-n s Run Sweave on the current .Rnw file. If choose is non-‘nil’, offer a menu of
available weavers.
[Command]ess-swv-latex
M-n l Run LaTeX after Sweave’ing.
[Command]ess-swv-PS
M-n p Generate and display a postscript file after LaTeX’ing.
[Command]ess-swv-PDF pdflatex-cmd
M-n P Generate and display a PDF file after LaTeX’ing. Optional argument pdflatex-
cmd is the command to use, which by default, is the command used to generate the
PDF file is the first element of ess-swv-pdflatex-commands.
[User Option]ess-swv-pdflatex-commands
Commands used by ess-swv-PDF to run a version of pdflatex; the first entry is the
default command.
Sweave’ing with ess-swv-weave starts an inferior-ESS process, if one is not available.
Other commands are available from the Sweaving, Tangling, ...’ submenu of the Noweb
menu.
AUCTeX (http://www.gnu.org/software/auctex) users may prefer to set the variable
ess-swv-plug-into-AUCTeX-p (available from the “ESS Sweave” customization group) to
t. Alternatively, the same can be achieved by activating the entry “AUCTeX Interface”
from the ‘Sweaving, Tangling, ...’ submenu, which toggles this variable on or off. When
the interface is activated, new entries for Sweave’ing and LaTeX’ing thereafter are available
from AUCTeX’s “Command” menu. Sweave’ing can, thus, be done by C-c C-c Sweave RET
without an inferior-ESS process. Similarly, LaTeX’ing can be done by C-c C-c LaTeXSweave
RET. In both cases, the process can be monitored with C-c C-l (TeX-recenter-output-
buffer). Open the viewer with C-c C-v (TeX-view), as usual in AUCTeX.