[R] Automate generation of multiple reports using odfWeave

Sarah Goslee sarah.goslee at gmail.com
Fri Feb 26 21:48:14 CET 2010


I tend to do it the other way around.

Hard-code the station into the ODT file as "thisstation".

Then, in R, do something like this:

allstations <- c("station1", "station2", "station3")

for (i in allstations) {
   thisstation <- i
   odfWeave("inputfile.odt", paste("output-", i, ".odt", sep=""))
}
rm(thisstation)

That way you don't have to have a bunch of files.

Sarah

On Fri, Feb 26, 2010 at 3:43 PM, Aleksey Naumov <anaumov at gmail.com> wrote:
> Dear R and odfWeave users,
>
> I am looking for a way to automate generation of many reports using
> odfWeave. All reports would use the same input ODT file, the only difference
> would be in the name of the dataset which will be analyzed in any particular
> report. Right now, the name of the dataset is hardcoded in the first code
> chuck in the input file:
>
> <<01 get data, echo=TRUE>>
> station = '123'                  # name of the station dataset to be
> analyzed in this report
> data = get_data(station)    # get data, e.g. from a database
> @
>
> This is far from ideal, as it requires a separate input file (ODT) for every
> input station, a huge duplication.
>
> Are there ways to streamline this? I am looking for a way to have only one
> input ODT file (much easier to maintain one file than many). I am thinking
> that the input file could be pre-processed to include the station parameter
> and saved as an intermediate ODT, which would then be put through
> odfWeave()? Does anyone know of a good way to edit the OO.org ODT file to
> put "station = '...'" into the first code chuck?
> Is there any other way to do that?
>
> Thank you,
> Aleksey

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list