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(1,1,'T',1,1,'T',0,1,'T',0,0,'T',1,1,'T',1,1,'T',1,1,'T',0,1,'T',0,1,'T',1,1,'T',0,0,'T',0,1,'T',0,1,'T',0,1,'T',0,0,'T',1,1,'T',1,1,'T',1,1,'T',0,1,'T',0,0,'T',1,1,'T',1,1,'T',0,0,'T',1,0,'T',1,1,'T',1,0,'T',1,1,'T',0,0,'T',0,0,'T',1,1,'T',1,0,'T',1,1,'T',0,0,'T',0,0,'T',0,0,'T',1,1,'T',1,1,'T',0,1,'E',0,1,'E',1,1,'E',1,1,'E',1,1,'E',1,1,'E',1,1,'E',0,0,'E',0,1,'E',0,1,'E',1,1,'E',1,1,'E',0,0,'E',0,1,'E',1,1,'E',0,1,'E',0,0,'E',0,1,'E',0,1,'E',0,1,'E',0,1,'E',0,0,'E',0,0,'E',0,1,'E',1,1,'E',1,1,'E',1,0,'E',0,0,'E',0,1,'E',0,1,'E',0,0,'E',1,1,'E',1,1,'E',0,1,'S',0,1,'S',0,1,'S',0,1,'S',1,1,'S',1,0,'S',0,0,'S',1,1,'S',1,0,'S',1,1,'S',0,0,'S',0,0,'S',0,0,'S',1,0,'S',0,0,'S',0,0,'S',1,0,'S',1,1,'S',0,0,'S',0,0,'S',1,1,'S',1,1,'S',1,1,'S',0,1,'S',1,1,'S',1,1,'S',1,1,'S',1,1,'S',0,0,'S',0,0,'S',1,1,'S',0,0,'S',0,0,'S',0,0,'S',0,1,'S'),dim=c(3,105),dimnames=list(c('pre','post','Treatment '),1:105)) > y <- array(NA,dim=c(3,105),dimnames=list(c('pre','post','Treatment '),1:105)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } There were 50 or more warnings (use warnings() to see the first 50) > par3 = 'Exact Pearson Chi-Squared by Simulation' > par2 = '2' > par1 = '1' > main = 'Association Plot' > par3 <- 'Exact Pearson Chi-Squared by Simulation' > par2 <- '2' > par1 <- '1' > #'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] [1,] "1" "1" "T" [2,] "1" "1" "T" [3,] "0" "1" "T" [4,] "0" "0" "T" [5,] "1" "1" "T" [6,] "1" "1" "T" [7,] "1" "1" "T" [8,] "0" "1" "T" [9,] "0" "1" "T" [10,] "1" "1" "T" [11,] "0" "0" "T" [12,] "0" "1" "T" [13,] "0" "1" "T" [14,] "0" "1" "T" [15,] "0" "0" "T" [16,] "1" "1" "T" [17,] "1" "1" "T" [18,] "1" "1" "T" [19,] "0" "1" "T" [20,] "0" "0" "T" [21,] "1" "1" "T" [22,] "1" "1" "T" [23,] "0" "0" "T" [24,] "1" "0" "T" [25,] "1" "1" "T" [26,] "1" "0" "T" [27,] "1" "1" "T" [28,] "0" "0" "T" [29,] "0" "0" "T" [30,] "1" "1" "T" [31,] "1" "0" "T" [32,] "1" "1" "T" [33,] "0" "0" "T" [34,] "0" "0" "T" [35,] "0" "0" "T" [36,] "1" "1" "T" [37,] "1" "1" "T" [38,] "0" "1" "E" [39,] "0" "1" "E" [40,] "1" "1" "E" [41,] "1" "1" "E" [42,] "1" "1" "E" [43,] "1" "1" "E" [44,] "1" "1" "E" [45,] "0" "0" "E" [46,] "0" "1" "E" [47,] "0" "1" "E" [48,] "1" "1" "E" [49,] "1" "1" "E" [50,] "0" "0" "E" [51,] "0" "1" "E" [52,] "1" "1" "E" [53,] "0" "1" "E" [54,] "0" "0" "E" [55,] "0" "1" "E" [56,] "0" "1" "E" [57,] "0" "1" "E" [58,] "0" "1" "E" [59,] "0" "0" "E" [60,] "0" "0" "E" [61,] "0" "1" "E" [62,] "1" "1" "E" [63,] "1" "1" "E" [64,] "1" "0" "E" [65,] "0" "0" "E" [66,] "0" "1" "E" [67,] "0" "1" "E" [68,] "0" "0" "E" [69,] "1" "1" "E" [70,] "1" "1" "E" [71,] "0" "1" "S" [72,] "0" "1" "S" [73,] "0" "1" "S" [74,] "0" "1" "S" [75,] "1" "1" "S" [76,] "1" "0" "S" [77,] "0" "0" "S" [78,] "1" "1" "S" [79,] "1" "0" "S" [80,] "1" "1" "S" [81,] "0" "0" "S" [82,] "0" "0" "S" [83,] "0" "0" "S" [84,] "1" "0" "S" [85,] "0" "0" "S" [86,] "0" "0" "S" [87,] "1" "0" "S" [88,] "1" "1" "S" [89,] "0" "0" "S" [90,] "0" "0" "S" [91,] "1" "1" "S" [92,] "1" "1" "S" [93,] "1" "1" "S" [94,] "0" "1" "S" [95,] "1" "1" "S" [96,] "1" "1" "S" [97,] "1" "1" "S" [98,] "1" "1" "S" [99,] "0" "0" "S" [100,] "0" "0" "S" [101,] "1" "1" "S" [102,] "0" "0" "S" [103,] "0" "0" "S" [104,] "0" "0" "S" [105,] "0" "1" "S" > (table1 <- table(z[,cat1],z[,cat2])) 0 1 0 30 26 1 8 41 > (V1<-dimnames(y)[[1]][cat1]) [1] "pre" > (V2<-dimnames(y)[[1]][cat2]) [1] "post" > postscript(file="/var/wessaorg/rcomp/tmp/19bdi1355752793.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/2f1x01355752793.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with simulated p-value (based on 2000 replicates) data: table1 X-squared = 15.6982, df = NA, p-value = 0.0004998 > 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/wessaorg/rcomp/tmp/3rwps1355752793.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/wessaorg/rcomp/tmp/4u9t41355752793.tab") > > try(system("convert tmp/19bdi1355752793.ps tmp/19bdi1355752793.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.503 0.225 1.879