[ESS] Is ess supposed to help with Sweave documents?
Thomas Lumley
tlumley at u.washington.edu
Wed Oct 27 21:00:43 CEST 2004
On Wed, 27 Oct 2004, Paul Johnson wrote:
> I was just learning how to do Sweave documents with Emacs & R. I did not
> find a simple 1-2-3 explanation of how this is supposed to go.
>
> It seems downright awkward. Am I doing this right?
>
> Open doc.Snw in emacs, fiddle that and save it, then do
>
> M-x R
>
> to start R, then in the R session
>
>> Sweave("doc.Snw")
>
> it says the tex file is ready for latex, so in emacs I open "doc.tex" and
> run latex on that. If "doc.tex" is already open, I have to revert buffer,
> then run latex on that. Several times I accidentally edited the tex file,
> when I should have been editing the Snw file.
>
I don't think you should open doc.tex -- since it is not intended to be
edited, Emacs should be kept well away from it.
There seem to be two straightforward ways to work
- invoke latex from within R
Sweave("doc.Snw")
system("latex doc.tex")
which could easily be automated into a single function (or even done by
ESS).
- write a Makefile (which seems to be the popular approach), so you can
just do
make doc.pdf
The following is then a useful shell script to run Sweave
#!/bin/sh
echo "library(tools);Sweave('"$1"')" | R --vanilla --silent
-thomas
More information about the ESS-help
mailing list