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