[R] Sweave: Variables in code chunk headers

Michael Hoffman b3i4old02 at sneakemail.com
Sat Dec 1 20:38:21 CET 2007


Dieter Menne wrote:
> 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.

Thanks. I guess what I really want to do is switch between one of two 
settings. Only one value can be in the defaults, and I would like some 
way of setting the other value. This might not be easily possible, but I 
thought I would ask.



More information about the R-help mailing list