[R] Sweaving single master file to get multiple individualised reports

Edith Hodgen Edith.Hodgen at nzcer.org.nz
Thu Nov 8 23:42:41 CET 2007


Hi

Apologies in advance if I've missed something obvious. I have read the
Sweave manual, the first article in R News, looked at the Help pages,
googled Sweave and words like loop, output, files, multiple, done much
the same on R site search (in case I missed something on Google) and I
couldn't find exactly what I'm after.

What I'm trying to do
—----------------------
Make individualised school (or regional or ...) reports combining
generic words, overall totals and individual results (in tables and
graphs), typically reporting student assessment data.

System info
—------------
Windows XP
R 2-5-1 (always wait for the R x-x-1 version)
Latest Miktex
Working in latest Emacs with the help of ESS & Auctex
Have (but seldom use) cygwin

What I think the problem is (I'm hoping it's not)
—------------------------------
I've used odfWeave to do something similar, and was then able to
specify both the infile and the outfile (and so could go something like
infile = template.odf and outfile = 
paste("ReportName",schoolname,".odt",sep = ""). 

[Why stop using odfWeave? a) runs slowly with all the zipping and
unzipping b) very cryptic error messages c) using eps to get high
quality graphics results in a somewhat flaky OpenOffice file where
scrolling through it to check pagination and table widths is really hard
d) turning the OpenOffice file into a pdf to send to the schools
requires an extra step or two that is both time-consuming and a nuisance
e) computer got very hot and bothered running a number of multipage
reports - to the point of having to be left to cool down before trying
again.]

This involved an R file that had

# getting packages, reading data etc stuff
:
:
# doing some pre-processing on project-wide totals- easier here where
it can be debugged bit by bit
:
:
for (i in 1:Nschools){
# set indicator variable for school i or otherwise set up subset for a
school
:
# more pre-processing for school/regional summaries
:
:
infile <- "templateName.odt"      # same for all schools/regions
outfile <- paste("ReportName",schoolname,".odt",sep = "")  # unique to
school/region
odfWeave(infile,outfile)
}

However, as far as I can see (admittedly, seldom very far) the
equivalent Sweave call is just Sweave(SnwFile) which would create
SnwFile.tex.

What I'm hoping for
—--------------------
Any one or more of:

- A blasting for lack of understanding that tells me it's all easy,
really (plus a "how to" or a "where to find and actually see")
- A work-around
- An idiot's guide to how to do it using a shell script or equivalent
(which I suspect to be the way to go)
- Help with automatically LaTeXing (actually pdfLaTeXing) all the 
*.tex files generated as a batch.

One advantage of the within-a-loop way of working is that when the
report for one or more schools needs re-running this can be done without
re-running the whole lot. This flexibility needs to be part of the final
solution.

Many thanks for any expertise and experience offered


Edith Hodgen
Statistician and Data Manager
New Zealand Council for Educational Research
Postal address: P.O. Box 3237, Wellington 6140
Street address: Level 10, Education House, 178-182 Willis Street,
                        Te Aro, Wellington 6011
Phone: +64-4-802 1433
Fax:      +64-4-384 7933
edith.hodgen at nzcer.org.nz

Web site http://www.nzcer.org.nz



More information about the R-help mailing list