[R] Sweave

Ista Zahn istazahn at gmail.com
Tue Feb 3 13:39:12 CET 2009


I strongly recommend using AucTeX for this. When inside a code chunk
emacs behaves just like it does in ess mode, and when not in a code
chunk emacs behaves like it usually does when editing LaTeX files in
AucTeX. It's pretty great.

As for your particular problem, I can't tell what's going on. If you
send a minimal, reproducible example, I'll be happy to run it through
Sweave and see what happens on my machine.

-Ista


From: Kjetil Halvorsen <kjetilbrinchmannhalvorsen at gmail.com>
To: "r-help at stat.math.ethz.ch" <R-help at stat.math.ethz.ch>
Date: Mon, 2 Feb 2009 17:57:49 -0300
Subject: [R] Sweave
I'm trying to (re)learn Sweave and run into some problems. I use now ubuntu
(8.10), emacs + ess.
Slowly getting upto speed on ess. I have a complete (hopefully) .Rnw  file,
but the resulting .tex
will not compile. The file does not contain anything exotic, but it produces
pdf figures, and that
is where the problems come:

 library(tools)
> Sweave("varioCoo.Rnw")
Writing to file varioCoo.tex
Processing code chunks ...
 1 : echo term verbatim (label=read)
Loading required package: coda
...
.
.
You can now run LaTeX on 'varioCoo.tex'
Warning messages:
 ... don think this are important
> texi2dvi("varioCoo.tex", pdf=T)
Error in texi2dvi("varioCoo.tex", pdf = T) :
 Running 'texi2dvi' on 'varioCoo.tex' failed.
LaTeX errors:
! You can't use `macro parameter character #' in horizontal mode.
<argument> ... system at active\string "\endcsname ##

l.111  bubble(NURE.orig, "ppm", col = c("#
                                         00ff0088", "#00ff0088"))
! You can't use `macro parameter character #' in horizontal mode.
<argument> ... system at active\string "\endcsname ##

l.111 ...NURE.orig, "ppm", col = c("#00ff0088", "#
                                                 00ff0088"))
!pdfTeX error: pdflatex (file ./varioCoo-fig2.pdf): PDF inclusion: required pag
e does not exist <0>
 ==> Fatal error occurred, no output PDF file produced!
> Sweave("varioCoo.Rnw")
Writing to file varioCoo.tex
Processing code chunks ...
 1 : echo term verbatim (label=read)
 2 : echo term verbatim (label=prep1)
 3 : echo term verbatim (label=prep2)
 4 : echo term verbatim eps pdf (label=fig2)
 5 : echo term verbatim eps pdf (label=fig3)
 6 : echo term verbatim eps pdf (label=fig4)

You can now run LaTeX on 'varioCoo.tex'
Warning message:
In readLines(f[1]) : incomplete final line found on 'varioCoo.Rnw'
> texi2dvi("varioCoo.tex", pdf=T)
Error in texi2dvi("varioCoo.tex", pdf = T) :
 Running 'texi2dvi' on 'varioCoo.tex' failed.
LaTeX errors:
! You can't use `macro parameter character #' in horizontal mode.
<argument> ... system at active\string "\endcsname ##

l.102  bubble(NURE.orig, "ppm", col = c("#
                                         00ff0088", "#00ff0088"))
! You can't use `macro parameter character #' in horizontal mode.
<argument> ... system at active\string "\endcsname ##

l.102 ...NURE.orig, "ppm", col = c("#00ff0088", "#
                                                 00ff0088"))
!pdfTeX error: pdflatex (file ./varioCoo-fig2.pdf): PDF inclusion: required pag

 ---: well, list.files() say that file exists.

e does not exist <0>
 ==> Fatal error occurred, no output PDF file produced!
>

The other problem refered to above comes from this source lines:

\begin{figure}
 \centering
 <<label=fig1,fig=TRUE,echo=TRUE>>=
 bubble(NURE.orig, "ppm", col = c("#00ff0088", "#00ff0088"))
@
\caption{Contenido de uranio (ppm)}

???

Kjetil
\end{figure}




More information about the R-help mailing list