[R] Sweave question: prevent expansion of unevaluated reused code chunk

Kevin R. Coombes krc at mdacc.tmc.edu
Wed Mar 14 00:02:52 CET 2007


Hi,

Consider the following (much simplified) Sweave example:

--------------

First, we set the value of $x$:
<<chunk1,eval=FALSE>>=
x <- 1
@

Then we set the value of $y$:
<<chunk2,eval=FALSE>>=
y <- 2
@

Thus, the overall algorithm has this structure:
<<combined,eval=FALSE>>=
<<chunk1>>
<<chunk2>>
@

<<justDoIt,echo=FALSE>>=
<<combined>>
@

---------------

I'd like to be able to do something like this, where the "combined" 
chunk prints out in the final LaTeX document essentially verbatim.  In 
particular, I want to see the "<<chunk1>>" unexpanded in that block, 
since this gives me a nice conceptual overview of the algorithm. (Of 
courser, this is more useful when chunk1 and chunk2 are much longer than 
they are in this example....)

Is there an option that allows me to get this behavior?

Thanks,
	Kevin



More information about the R-help mailing list