[R] how to use \Sexpr{} with sweave

cryan at binghamton.edu cryan at binghamton.edu
Sun Oct 7 04:38:04 CEST 2007

I'm trying to learn Sweave.  So far things are going well with the chunks of code identified by << >>=

But I'm having trouble with the in-line text use of \Sexpr.

Here is a short example .Rnw file:






The .tex file that it yields contains 

\Sexpr{2+6} as its next-to-last line.  \usepackage{Sweave} is in its preamble.

When I pdflatex that file, the resulting pdf file shows the proper value of pnorm(1), but it does not contain "8" near its end.  Instead it contains "2+6".  I had expected the computed value.

Also, pdflatex gives me a message that "there was an error opening the document.  The file cannot be found." I have to go find it and open it, instead of it opening automatically like a non-problematic case would.

Running R 2.5.1 on WinXP, with MikTex.

Any advice? Thanks.

--Chris Ryan

More information about the R-help mailing list