From b3i4old02 at sneakemail.com  Sun Dec  2 02:45:53 2007
From: b3i4old02 at sneakemail.com (Michael Hoffman)
Date: Sun, 02 Dec 2007 01:45:53 +0000
Subject: [Rd] [R] Sweave: Variables in code chunk headers
In-Reply-To: <4751CA79.6060507@stats.uwo.ca>
References: <fis1g7$65a$1@ger.gmane.org>	<loom.20071201T171543-701@post.gmane.org>	<fisd7m$85f$1@ger.gmane.org>
	<4751CA79.6060507@stats.uwo.ca>
Message-ID: <fit2oq$ujf$1@ger.gmane.org>

Duncan Murdoch wrote:

> On 01/12/2007 2:38 PM, Michael Hoffman wrote:
>> 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.
> 
> My understanding is that Michael wants to have the Sweave options in a 
> chunk depend on a calculation happening in the underlying R session. 

That would be really nice and allow some things I hadn't even imagined 
would be possible.

But really I just would like the ability to set a variable statically 
and reuse it. Using a macro system like m4 would work, although I 
dislike the idea of adding yet another macro system to my poor document.



[Rd] [R] Sweave: Variables in code chunk headers
Michael Hoffman