R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(2 + ,1 + ,NA + ,0 + ,0 + ,0 + ,0 + ,1 + ,2 + ,1 + ,NA + ,1 + ,1 + ,0 + ,0 + ,1 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,1 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,1 + ,0 + ,2 + ,1 + ,NA + ,1 + ,0 + ,0 + ,0 + ,0 + ,2 + ,1 + ,NA + ,0 + ,0 + ,0 + ,1 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,1 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,1 + ,2 + ,1 + ,NA + ,1 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,1 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,1 + ,2 + ,1 + ,NA + ,0 + ,0 + ,0 + ,0 + ,1 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,0 + ,0 + ,0 + ,0 + ,0 + ,2 + ,0 + ,NA + ,1 + ,1 + ,0 + ,0 + ,0 + ,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come') + ,1:68)) > y <- array(NA,dim=c(8,68),dimnames=list(c('Weeks','UseLimit','T40','T20','Used','CorrectAnalysis','Useful','Outcome'),1:68)) > 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 = '4' > main = 'Association Plot' > par3 <- 'Pearson Chi-Squared' > par2 <- '8' > par1 <- '4' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: > #Technical description: > library(vcd) Loading required package: MASS Loading required package: grid Loading required package: colorspace > 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,])))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 2 1 NA 0 0 0 0 1 [2,] 2 1 NA 1 1 0 0 1 [3,] 2 0 NA 0 0 0 0 0 [4,] 2 0 NA 0 0 0 0 1 [5,] 2 0 NA 0 0 0 1 0 [6,] 2 1 NA 1 0 0 0 0 [7,] 2 1 NA 0 0 0 1 0 [8,] 2 0 NA 0 0 0 0 0 [9,] 2 0 NA 1 0 0 0 0 [10,] 2 0 NA 0 0 0 0 1 [11,] 2 1 NA 1 0 0 0 0 [12,] 2 0 NA 0 0 0 0 0 [13,] 2 1 NA 0 0 0 0 0 [14,] 2 0 NA 0 0 0 0 1 [15,] 2 1 NA 0 0 0 0 1 [16,] 2 0 NA 0 0 0 0 0 [17,] 2 0 NA 0 0 0 0 0 [18,] 2 0 NA 0 0 0 0 0 [19,] 2 0 NA 1 1 0 0 0 [20,] 2 0 NA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67,] 2 1 NA 0 1 1 1 0 [68,] 2 1 NA 0 1 0 0 0 > (table1 <- table(z[,cat1],z[,cat2])) 0 1 0 34 17 1 13 4 > (V1<-dimnames(y)[[1]][cat1]) [1] "T20" > (V2<-dimnames(y)[[1]][cat2]) [1] "Outcome" > postscript(file="/var/fisher/rcomp/tmp/138741356129103.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() null device 1 > > #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/2rdyf1356129103.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with Yates' continuity correction data: table1 X-squared = 0.2067, df = 1, p-value = 0.6494 > 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/37nc91356129103.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/40bys1356129103.tab") > > try(system("convert tmp/138741356129103.ps tmp/138741356129103.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.424 0.338 1.770