[R] Sweave: Variables in code chunk headers

Dieter Menne dieter.menne at menne-biomed.de
Sat Dec 1 18:16:57 CET 2007


Michael Hoffman <b3i4old02 <at> sneakemail.com> writes:

> 
> I would like to be able to do something like this:
> 
>    <<echo=F,fig=T,width=mywidth>>=
>    ...
>    @
> 
> with mywidth set in a previous code chunk. Is there a way to do this in 
> Sweave?
> 

Not in the <<>>, but you could set a hook for fig:


>From Sweave docs:

If option "SweaveHooks" is defined as list(fig = foo), and foo is a function,
then it would be executed before the code in each figure chunk. This is
especially useful to set defaults for the graphical parameters in a series of
figure chunks.

Dieter



More information about the R-help mailing list