[R] odfTable in loop

SJ saimon at student.ethz.ch
Tue Oct 21 15:18:21 CEST 2008


Dear list

I try to create a report with several (an unknown number of) tables  
via odfTable.

The following code results in the expected XML structure:

##################
   scores.1=new.env()
   scores.1$cont.tab=rbind(c(3,5),c(6,8))
   scores.2=new.env()
   scores.2$cont.tab=rbind(c(2,9),c(7,6))

   test=get(paste("scores.1",sep=''))

   colnames(test$cont.tab)=c("yes","no")
   rownames(test$cont.tab)=c("yes","no")

   odfTable(test$cont.tab)
   odfTableCaption("2x2 Contingency table for experiment 1")
##################

But when I try to run this within a for-loop, the XML-output is  
suppressed and only the table caption is written:

##################
for(i in c(1,2)){
   test=get(paste("scores.",i,sep=''))

   colnames(test$cont.tab)=c("yes","no")
   rownames(test$cont.tab)=c("yes","no")

   odfTable(test$cont.tab,header="Observations")
   odfTableCaption(paste("2x2 Contingency table for experiment",i))
}
##################

What I am doing wrong?

Thanks and best regards
Simon



More information about the R-help mailing list