From b3i4old02 at sneakemail.com  Sun Dec  2 20:41:04 2007
From: b3i4old02 at sneakemail.com (Michael Hoffman)
Date: Sun, 02 Dec 2007 19:41:04 +0000
Subject: [Rd] [R] Sweave: Variables in code chunk headers
In-Reply-To: <47529A15.3000100@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>	<fit2oq$ujf$1@ger.gmane.org>
	<47529A15.3000100@stats.uwo.ca>
Message-ID: <fiv1or$qfs$1@ger.gmane.org>

Duncan Murdoch wrote:

> I put together a clunky way to handle that for a presentation last week; 
> it may be enough for you.
> 
> I leave the Sweave options at their defaults, but I have code chunks 
> that affect the appearance, and I run those without echoing to switch 
> between a couple of formats.  For example, I have some pages that 
> display one figure, and others that display two.

That is a decent way of doing what I am suggesting. Probably too 
complicated to be worth it if I am just changing one variable.

> One other thing that would have helped with this approach would be a way 
> to include another file:  then I wouldn't have to repeat those 
> definitions in every Rnw of the project.

Yet another candidate for (yet another) pre-processing step. :)

Of course, you could load the complicated bits in another file with 
source(). You'd still have to redefine <<single>> and <<double>> 
everywhere, but at least you would be able to change the option settings 
easily. Like this:

<<echo=F>>
source("init.R")
@

<<single, echo=F, eval=F>>=
setup.single() # loaded from init.R
@



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