x <- array(list(4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Good'
,4
,'Yes'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'Yes'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'Yes'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Good'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'Treatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'Yes'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'Yes'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'UsedStats'
,'Yes'
,'No'
,'Good'
,4
,'No'
,'Treatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'Yes'
,'NoTreatment'
,NA
,'UsedStats'
,'No'
,'No'
,'Good'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'UsedStats'
,'Yes'
,'No'
,'Bad'
,4
,'No'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'Yes'
,'Good'
,4
,'Yes'
,'NoTreatment'
,NA
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Bad'
,2
,'Yes'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'Yes'
,'Bad'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'UsedStats'
,'No'
,'Yes'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'UsedStats'
,'No'
,'Yes'
,'Good'
,2
,'Yes'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'Yes'
,'Good'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'UsedStats'
,'Yes'
,'No'
,'Good'
,2
,'No'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Bad'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'No'
,NA
,'Treatment'
,'UsedStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'Treatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Bad'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'Yes'
,'Good'
,2
,'No'
,NA
,'NoTreatment'
,'NoStats'
,'No'
,'No'
,'Good'
,2
,'Yes'
,NA
,'NoTreatment'
,'UsedStats'
,'Yes'
,'No'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'UsedStats'
,'Yes'
,'Yes'
,'Bad'
,2
,'Yes'
,NA
,'NoTreatment'
,'UsedStats'
,'No'
,'No'
,'Bad')
,dim=c(8
,154)
,dimnames=list(c('Weeks'
,'UseLimit'
,'T40'
,'T20'
,'Used'
,'CorrectAnalysis'
,'Useful'
,'Outcome')
,1:154))
 y <- array(NA,dim=c(8,154),dimnames=list(c('Weeks','UseLimit','T40','T20','Used','CorrectAnalysis','Useful','Outcome'),1:154))
 for (i in 1:dim(x)[1])
 {
 	for (j in 1:dim(x)[2])
 	{
 		y[i,j] <- as.numeric(x[i,j])
 	}
 }
par3 = 'Pearson Chi-Squared'
par2 = '8'
par1 = '3'
main = 'Association Plot'
library(vcd)
cat1 <- as.numeric(par1) #
cat2<- as.numeric(par2) #
simulate.p.value=FALSE
if (par3 == 'Exact Pearson Chi-Squared by Simulation') simulate.p.value=TRUE
x <- t(x)
(z <- array(unlist(x),dim=c(length(x[,1]),length(x[1,]))))
(table1 <- table(z[,cat1],z[,cat2]))
(V1<-dimnames(y)[[1]][cat1])
(V2<-dimnames(y)[[1]][cat2])
postscript(file="/var/fisher/rcomp/tmp/1w4cz1356106886.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) 
assoc(ftable(z[,cat1],z[,cat2],row.vars=1,dnn=c(V1,V2)),shade=T)
dev.off()

#Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
load(file="/var/fisher/rcomp/createtable")

a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Tabulation of Results',ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, ' ', 1,TRUE)
for(nc in 1:ncol(table1)){
a<-table.element(a, colnames(table1)[nc], 1, TRUE)
}
a<-table.row.end(a)
for(nr in 1:nrow(table1) ){
a<-table.element(a, rownames(table1)[nr], 1, TRUE)
for(nc in 1:ncol(table1) ){
a<-table.element(a, table1[nr, nc], 1, FALSE)
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/258p61356106886.tab") 
(cst<-chisq.test(table1, simulate.p.value=simulate.p.value) )
if (par3 == 'McNemar Chi-Squared') {
(cst <- mcnemar.test(table1))
}
if (par3=='Fisher Exact Test') {
(cst <- fisher.test(table1))
}
if ((par3 != 'McNemar Chi-Squared') & (par3 != 'Fisher Exact Test')) {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Tabulation of Expected Results',ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, ' ', 1,TRUE)
for(nc in 1:ncol(table1)){
a<-table.element(a, colnames(table1)[nc], 1, TRUE)
}
a<-table.row.end(a)
for(nr in 1:nrow(table1) ){
a<-table.element(a, rownames(table1)[nr], 1, TRUE)
for(nc in 1:ncol(table1) ){
a<-table.element(a, round(cst$expected[nr, nc], digits=2), 1, FALSE)
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/39pgh1356106886.tab") 
}
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Statistical Results',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, cst$method, 2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
if (par3=='Pearson Chi-Squared') a<-table.element(a, 'Pearson Chi Square Statistic', 1, TRUE)
if (par3=='Exact Pearson Chi-Squared by Simulation') a<-table.element(a, 'Exact Pearson Chi Square Statistic', 1, TRUE)
if (par3=='McNemar Chi-Squared') a<-table.element(a, 'McNemar Chi Square Statistic', 1, TRUE)
if (par3=='Fisher Exact Test') a<-table.element(a, 'Odds Ratio', 1, TRUE)
if (par3=='Fisher Exact Test') {
if ((ncol(table1) == 2) & (nrow(table1) == 2)) {
a<-table.element(a, round(cst$estimate, digits=2), 1,FALSE)
} else {
a<-table.element(a, '--', 1,FALSE)
}
} else {
a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE)
}
a<-table.row.end(a)
if(!simulate.p.value){
if(par3!='Fisher Exact Test') {
a<-table.row.start(a)
a<-table.element(a, 'Degrees of Freedom', 1, TRUE)
a<-table.element(a, cst$parameter, 1,FALSE)
a<-table.row.end(a)
}
}
a<-table.row.start(a)
a<-table.element(a, 'P value', 1, TRUE)
a<-table.element(a, round(cst$p.value, digits=2), 1,FALSE)
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/var/fisher/rcomp/tmp/4llfu1356106886.tab") 

try(system("convert tmp/1w4cz1356106886.ps tmp/1w4cz1356106886.png",intern=TRUE))

