[R] Sweave : change value in rnw file to generate multiple "single" reports ?

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Dec 10 17:52:22 CET 2007


Within or before SWeave, you can use R.
Hence you can write some R function that first changes the rnw and runs 
SWeave thereafter, or even better, write something in your SWeave code 
that reads a user customized variables, e.g. from an environment 
variable or from some text file.

Uwe Ligges



Ptit_Bleu wrote:
> Hello,
> 
> I'm still trying to make the life of my colleagues easier. Nice, isn't it ?
> At the moment, I'm looking for a way to generate multiple "single report".
> In fact I have a .rnw file which send a query to a MySQL database
> (rs<-dbSendQuery(con, statement="select * from treatdata where
> name='Device1'")
> 
> But of course my colleagues have many devices and don't want to enter the
> rnw file to change the name of the device.
> 
> Is there a way to pass arguments to Sweave like Sweave("myfile.rnw",
> namevar="Device2") and it will change namevar by Device2 into the file
> myfile.rnw before creating the .tex file ?
> Or is it possible to do it via another language, that is: loading the rnw
> file, modifying it, saving it and finally calling Sweave ?
> 
> Whatever the solution, I need you help. In advance thank you.
> Ptit Bleu.



More information about the R-help mailing list