Here is an example .Rnw file (called "example.rnw"):
\documentclass{article} \begin{document} <<a>>= x <- 1:10 x @ <<b>>= y <- 10:1 y @ <<c>>= z <- 1:5 z @ \clearpage \input{example-purl.tex} \end{document}
If you create a file in your working directory called "template.rnw" that contains only:
<<%sCHUNK_LABEL_HERE, eval=FALSE>>= @
Then you run:
stitch(purl("example.rnw",output="example-purl.r"),template="template.rnw") knit("example.rnw")
It makes sense? Basically, you purl ing, stitch with the purl ed, knit ting code of the source document, and then compile the resulting LaTeX ("example.tex"), which includes knit ting and purl ING. Everything should be formatted beautifully (and sequentially).
source share