Rev 89867 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\documentclass[a4paper]{article}\title{Finer control of weaving and tangling}\author{Vincent Goulet and R Core Team}\begin{document}\maketitleThe following code chunk contains a deliberate error, say fordidactic purposes. Using the option \texttt{eval=FALSE} avoids anerror with Sweave, but the chunk is commented out by Stangle.<<main, eval=FALSE>>=2 + does.not.exist@With \texttt{ignore.on.weave=TRUE} (or \texttt{weave=FALSE}), thefollowing chunk is neither parsed nor evaluated by Sweave (hencemissing from the PDF file). Therefore, the chunk may containunparsable R code. However, the code is extracted as usual byStangle, without being commented out.<<main, ignore.on.weave=TRUE>>=2 a@We remove the chunk separator before this next chunk. It willappear immediately after the previous one in the tangled script.<<main, chunk.sep=FALSE>>=pi@Pairing \texttt{ignore.on.weave=TRUE} with the option\texttt{extension} allows to keep, in a single source file, Rcode as well as text or code in other programming languages thatshould not be evaluated by Sweave.<<hello, extension=sh, prefix=FALSE, ignore.on.weave=TRUE>>=#!/bin/shecho "Hello, World!"exit 0@<<README, extension=FALSE, prefix=FALSE, ignore.on.weave=TRUE>>=Hello, World!@Finally, a chunk processed normally by Sweave, but ignored byStangle. This is convenient with \texttt{split = TRUE} to avoidlittering the output directory with unimportant scripts.<<ignore.on.tangle=TRUE>>=x <- rnorm(10)@\end{document}