Brief answer:
Apply these options: prefix=T
then eval=F
Long answer:
Make the figures as separate files, then disable the chunk evaluation and include PDF of the figure.
prefix=T
: filenames of figures are generated with common prefix (by default the name of the source file).
eval=F
: The code chunk is not evaluated, and hence no text or graphical output created.
Play with the options in this MWE:
\documentclass{article}
\begin{document}
The A chunk
<<a,echo=T,eval=T,results=hide>>=
a <-2+3
a
@
The B chunk
<<b,echo=T,eval=T,fig=T,prefix=T,results=verbatim>>=
b <- a+3
b
cars <- c(1, 3, 6, 4, 9)
plot(cars)
@
\end{document}
Other options of some interest could be results=hide
(output is suppressed, but code is executed).
However, even if you can disable the evaluation or the ouput of some chunks, may be this cannot help significantly with some large documents, as the result of a chunk often depend of earlier chunks, that is a pain switch on and off to avoid the rendering of some figures.
To test some chunk at the beginning or middle of the document and skipping all subsequent chunks, the faster is simply add a \end{document}
after it.
`