[R] Sweave: looping over mixed R/LaTeX code

Dieter Menne dieter.menne at menne-biomed.de
Fri Jun 13 12:47:19 CEST 2008


Stephan Kolassa <Stephan.Kolassa <at> gmx.de> writes:

> I would like to loop over a medium amount of Sweave code, including both R and
LaTeX chunks. Is there any way to
> do so? As an illustration, can I create a .tex file like this using a loop
within a .Rnw file, where the
> "1,2,3" comes from some iteration variable in R?
> 
> ################################################
> \documentclass{article}
> \usepackage{Sweave}
> \begin{document}
> Iteration 1
> Iteration 2
> Iteration 3
> \end{document}
> ################################################

I normally do this with a \newcommand: all latex stuff in the newcommand{},
passing parameters created by R.

Dieter



More information about the R-help mailing list