Skip to content
Prev 22060 / 63424 Next

Sweave processes \Sexpr in commented LaTeX source

Marc,
I have often the same problem, I'm using a construct like :

<<eval=F>>=
x <- rnorm(100)
@

I have \Sexpr{ifelse(exists("x"), length(x), "???")} elements
in vector x.

This works well for me, and you have more control than a global
\SweaveOpts{eval.Sexpr=false} would allow, for instance :

<<TimeConsumingCodeChunk1,eval=F>>=
x <- rnorm(100)
...
@

I have \Sexpr{ifelse(exists("x"), length(x), "Ooops, I forgot
to evaluate TimeConsumingCodeChunk1")} elements in vector x.

Wouldn't it be enough to mention this in Sweave's FAQ ?

Best,

Jean