Background:
I have course notes on R, written using Sweave. I want to provide the R code separately so the course attendees don't have to re-type everthing in the manual.
In this manual, I typically show a command, then re-use the chunk to produce a plot. Something like this:
%% first, show how the plot is done... <<ex.ts.acf.mottle,echo=TRUE,fig=FALSE>>= par(mfrow=c(2,2)) mottle.acf <- acf(mottle.t[,1], lag.max=45) mottle.pacf <- pacf(mottle.t[,1], lag.max=45) mottle.acf <- acf(mottle.t[,1], lag.max=45, ci.type="ma") mottle.pacf <- pacf(mottle.t[,1], lag.max=45, ci.type="ma")
@
%% then plot it.
\begin{figure}[tbh]
\centering
<<echo=FALSE,fig=TRUE>>=
<<ex.ts.acf.mottle>>
@
\caption{Autocorrelation plot of the \Data{mottle} dataset.}
\label{fig:ex.ts.acf.mottle}
\end{figure}
%% example endsStangle will (correctly) print the <<ex.ts.acf.mottle>> chunk twice, since it is called twice; once to create it, and once to re-use it.
Cheers
Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 [EMAIL PROTECTED]
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
