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(0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,1,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,1,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,0,4,0,4,1,4,0,4,0,4,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,1,2,1,2,0,2),dim=c(2,154),dimnames=list(c('CorrectAnalysis','Weeks'),1:154)) > y <- array(NA,dim=c(2,154),dimnames=list(c('CorrectAnalysis','Weeks'),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 = '1' > par1 = '2' > main = 'Association Plot' > 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] [1,] 0 4 [2,] 0 4 [3,] 0 4 [4,] 0 4 [5,] 0 4 [6,] 0 4 [7,] 0 4 [8,] 0 4 [9,] 0 4 [10,] 0 4 [11,] 0 4 [12,] 0 4 [13,] 0 4 [14,] 0 4 [15,] 0 4 [16,] 0 4 [17,] 1 4 [18,] 0 4 [19,] 0 4 [20,] 1 4 [21,] 0 4 [22,] 0 4 [23,] 0 4 [24,] 0 4 [25,] 0 4 [26,] 0 4 [27,] 0 4 [28,] 0 4 [29,] 0 4 [30,] 0 4 [31,] 0 4 [32,] 0 4 [33,] 0 4 [34,] 0 4 [35,] 0 4 [36,] 0 4 [37,] 0 4 [38,] 0 4 [39,] 0 4 [40,] 0 4 [41,] 1 4 [42,] 0 4 [43,] 0 4 [44,] 0 4 [45,] 0 4 [46,] 0 4 [47,] 0 4 [48,] 0 4 [49,] 0 4 [50,] 0 4 [51,] 0 4 [52,] 1 4 [53,] 0 4 [54,] 1 4 [55,] 0 4 [56,] 0 4 [57,] 0 4 [58,] 0 4 [59,] 0 4 [60,] 1 4 [61,] 0 4 [62,] 0 4 [63,] 0 4 [64,] 0 4 [65,] 0 4 [66,] 0 4 [67,] 1 4 [68,] 0 4 [69,] 0 4 [70,] 0 4 [71,] 0 4 [72,] 0 4 [73,] 0 4 [74,] 0 4 [75,] 0 4 [76,] 0 4 [77,] 0 4 [78,] 0 4 [79,] 1 4 [80,] 0 4 [81,] 0 4 [82,] 0 4 [83,] 0 4 [84,] 1 4 [85,] 0 4 [86,] 0 4 [87,] 0 2 [88,] 0 2 [89,] 0 2 [90,] 0 2 [91,] 0 2 [92,] 0 2 [93,] 0 2 [94,] 0 2 [95,] 0 2 [96,] 0 2 [97,] 0 2 [98,] 0 2 [99,] 0 2 [100,] 0 2 [101,] 0 2 [102,] 0 2 [103,] 0 2 [104,] 0 2 [105,] 0 2 [106,] 0 2 [107,] 0 2 [108,] 0 2 [109,] 0 2 [110,] 0 2 [111,] 0 2 [112,] 0 2 [113,] 0 2 [114,] 0 2 [115,] 0 2 [116,] 0 2 [117,] 0 2 [118,] 0 2 [119,] 0 2 [120,] 0 2 [121,] 0 2 [122,] 0 2 [123,] 0 2 [124,] 0 2 [125,] 0 2 [126,] 0 2 [127,] 0 2 [128,] 0 2 [129,] 0 2 [130,] 0 2 [131,] 0 2 [132,] 0 2 [133,] 0 2 [134,] 0 2 [135,] 0 2 [136,] 0 2 [137,] 0 2 [138,] 0 2 [139,] 0 2 [140,] 0 2 [141,] 1 2 [142,] 0 2 [143,] 0 2 [144,] 0 2 [145,] 0 2 [146,] 0 2 [147,] 0 2 [148,] 0 2 [149,] 0 2 [150,] 0 2 [151,] 0 2 [152,] 1 2 [153,] 1 2 [154,] 0 2 > (table1 <- table(z[,cat1],z[,cat2])) 0 1 2 65 3 4 77 9 > (V1<-dimnames(y)[[1]][cat1]) [1] "Weeks" > (V2<-dimnames(y)[[1]][cat2]) [1] "CorrectAnalysis" > postscript(file="/var/wessaorg/rcomp/tmp/1hbqt1356135025.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/2pkrl1356135025.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with Yates' continuity correction data: table1 X-squared = 1.1858, df = 1, p-value = 0.2762 > 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/37mf31356135025.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/442jd1356135025.tab") > > try(system("convert tmp/1hbqt1356135025.ps tmp/1hbqt1356135025.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.574 0.168 1.718