Others have given some good advice, and what works best for you will depend on exactly what you want to do and how you think about the problem. Here are just a couple of other ideas to throw into the mix.
If you want to edit the .rnw file, then the tools sed, awk, or perl (or probably several others) can all do this quite easily. For example if you have a file (base.rnw) that has MYDEVICE everywhere that you want to replace with Device2 or whatever then the following command at a command prompt will create a new file (dev2.rnw) that is a copy of base.rnw with all occurences of MYDEVICE replaced with Device2: perl -pe "s/MYDEVICE/Device2/g" base.rnw > dev2.rnw Another tool that you may want to learn is "make". You can set up a makefile that shows how each file relates to the next in a chain of steps, then just type something like: make device2.pdf At the command line and it will automatically make the changes to your .rnw file and possibly to data or other files involved, then run all the steps needed to create device2.pdf, then deletes all the intermediate files that you don't need (device2.dvi, ...). It also has the benefit of being able to update all the appropriate files when you update a data file, script file, or .rnw file. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ptit_Bleu > Sent: Monday, December 10, 2007 9:26 AM > To: r-help@r-project.org > Subject: [R] Sweave : change value in rnw file to generate > multiple "single" reports ? > > > 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. > -- > View this message in context: > http://www.nabble.com/Sweave-%3A-change-value-in-rnw-file-to-g > enerate-multiple-%22single%22-reports---tp14256204p14256204.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.