R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(41 + ,38 + ,39 + ,32 + ,30 + ,35 + ,31 + ,33 + ,34 + ,37 + ,35 + ,29 + ,39 + ,31 + ,34 + ,36 + ,36 + ,35 + ,37 + ,38 + ,38 + ,31 + ,36 + ,34 + ,38 + ,35 + ,39 + ,38 + ,33 + ,37 + ,32 + ,33 + ,36 + ,32 + ,38 + ,38 + ,39 + ,38 + ,32 + ,32 + ,32 + ,33 + ,31 + ,31 + ,39 + ,38 + ,37 + ,39 + ,39 + ,32 + ,41 + ,32 + ,36 + ,35 + ,33 + ,37 + ,33 + ,33 + ,34 + ,33 + ,31 + ,28 + ,27 + ,32 + ,37 + ,31 + ,34 + ,37 + ,34 + ,30 + ,32 + ,33 + ,29 + ,31 + ,36 + ,33 + ,29 + ,31 + ,35 + ,33 + ,37 + ,32 + ,34 + ,33 + ,38 + ,32 + ,35 + ,33 + ,38 + ,28 + ,37 + ,35 + ,38 + ,39 + ,33 + ,34 + ,36 + ,38 + ,38 + ,32 + ,32 + ,38 + ,32 + ,30 + ,32 + ,33 + ,34 + ,38 + ,32 + ,32 + ,37 + ,32 + ,39 + ,34 + ,29 + ,34 + ,37 + ,36 + ,35 + ,34 + ,30 + ,28 + ,38 + ,34 + ,34 + ,35 + ,31 + ,35 + ,34 + ,31 + ,35 + ,37 + ,36 + ,35 + ,30 + ,27 + ,39 + ,40 + ,35 + ,37 + ,38 + ,36 + ,31 + ,38 + ,34 + ,39 + ,38 + ,41 + ,34 + ,27 + ,39 + ,30 + ,37 + ,37 + ,34 + ,31 + ,28 + ,31 + ,37 + ,27 + ,33 + ,36 + ,37 + ,38 + ,35 + ,37 + ,37 + ,33 + ,32 + ,34 + ,33 + ,31 + ,38 + ,39 + ,33 + ,34 + ,29 + ,32 + ,33 + ,33 + ,31 + ,36 + ,36 + ,32 + ,35 + ,41 + ,32 + ,28 + ,29 + ,30 + ,39 + ,36 + ,37 + ,35 + ,35 + ,31 + ,37 + ,34 + ,32 + ,36 + ,38 + ,36 + ,37 + ,35 + ,36 + ,37 + ,32 + ,28 + ,33 + ,39 + ,40 + ,32 + ,38 + ,35 + ,41 + ,39 + ,36 + ,35 + ,43 + ,42 + ,30 + ,34 + ,31 + ,33 + ,32 + ,41 + ,32 + ,33 + ,37 + ,34 + ,37 + ,32 + ,33 + ,40 + ,34 + ,40 + ,33 + ,35 + ,38 + ,36 + ,33 + ,37 + ,31 + ,27 + ,38 + ,39 + ,37 + ,38 + ,33 + ,31 + ,31 + ,33 + ,39 + ,32 + ,44 + ,39 + ,33 + ,36 + ,35 + ,33 + ,32 + ,33 + ,28 + ,32 + ,40 + ,37 + ,27 + ,30 + ,37 + ,38 + ,32 + ,29 + ,28 + ,22 + ,34 + ,35 + ,30 + ,35 + ,35 + ,34 + ,31 + ,35 + ,32 + ,34 + ,30 + ,34 + ,30 + ,35 + ,31 + ,23 + ,40 + ,31 + ,32 + ,27 + ,36 + ,36 + ,32 + ,31 + ,35 + ,32 + ,38 + ,39 + ,42 + ,37 + ,34 + ,38 + ,35 + ,39 + ,35 + ,34 + ,33 + ,31 + ,36 + ,32 + ,32 + ,37 + ,33 + ,36 + ,34 + ,32 + ,32 + ,35 + ,34 + ,36) + ,dim=c(2 + ,162) + ,dimnames=list(c('Connected' + ,'Separate') + ,1:162)) > y <- array(NA,dim=c(2,162),dimnames=list(c('Connected','Separate'),1:162)) > 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' > #'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,] 41 38 [2,] 39 32 [3,] 30 35 [4,] 31 33 [5,] 34 37 [6,] 35 29 [7,] 39 31 [8,] 34 36 [9,] 36 35 [10,] 37 38 [11,] 38 31 [12,] 36 34 [13,] 38 35 [14,] 39 38 [15,] 33 37 [16,] 32 33 [17,] 36 32 [18,] 38 38 [19,] 39 38 [20,] 32 32 [21,] 32 33 [22,] 31 31 [23,] 39 38 [24,] 37 39 [25,] 39 32 [26,] 41 32 [27,] 36 35 [28,] 33 37 [29,] 33 33 [30,] 34 33 [31,] 31 28 [32,] 27 32 [33,] 37 31 [34,] 34 37 [35,] 34 30 [36,] 32 33 [37,] 29 31 [38,] 36 33 [39,] 29 31 [40,] 35 33 [41,] 37 32 [42,] 34 33 [43,] 38 32 [44,] 35 33 [45,] 38 28 [46,] 37 35 [47,] 38 39 [48,] 33 34 [49,] 36 38 [50,] 38 32 [51,] 32 38 [52,] 32 30 [53,] 32 33 [54,] 34 38 [55,] 32 32 [56,] 37 32 [57,] 39 34 [58,] 29 34 [59,] 37 36 [60,] 35 34 [61,] 30 28 [62,] 38 34 [63,] 34 35 [64,] 31 35 [65,] 34 31 [66,] 35 37 [67,] 36 35 [68,] 30 27 [69,] 39 40 [70,] 35 37 [71,] 38 36 [72,] 31 38 [73,] 34 39 [74,] 38 41 [75,] 34 27 [76,] 39 30 [77,] 37 37 [78,] 34 31 [79,] 28 31 [80,] 37 27 [81,] 33 36 [82,] 37 38 [83,] 35 37 [84,] 37 33 [85,] 32 34 [86,] 33 31 [87,] 38 39 [88,] 33 34 [89,] 29 32 [90,] 33 33 [91,] 31 36 [92,] 36 32 [93,] 35 41 [94,] 32 28 [95,] 29 30 [96,] 39 36 [97,] 37 35 [98,] 35 31 [99,] 37 34 [100,] 32 36 [101,] 38 36 [102,] 37 35 [103,] 36 37 [104,] 32 28 [105,] 33 39 [106,] 40 32 [107,] 38 35 [108,] 41 39 [109,] 36 35 [110,] 43 42 [111,] 30 34 [112,] 31 33 [113,] 32 41 [114,] 32 33 [115,] 37 34 [116,] 37 32 [117,] 33 40 [118,] 34 40 [119,] 33 35 [120,] 38 36 [121,] 33 37 [122,] 31 27 [123,] 38 39 [124,] 37 38 [125,] 33 31 [126,] 31 33 [127,] 39 32 [128,] 44 39 [129,] 33 36 [130,] 35 33 [131,] 32 33 [132,] 28 32 [133,] 40 37 [134,] 27 30 [135,] 37 38 [136,] 32 29 [137,] 28 22 [138,] 34 35 [139,] 30 35 [140,] 35 34 [141,] 31 35 [142,] 32 34 [143,] 30 34 [144,] 30 35 [145,] 31 23 [146,] 40 31 [147,] 32 27 [148,] 36 36 [149,] 32 31 [150,] 35 32 [151,] 38 39 [152,] 42 37 [153,] 34 38 [154,] 35 39 [155,] 35 34 [156,] 33 31 [157,] 36 32 [158,] 32 37 [159,] 33 36 [160,] 34 32 [161,] 32 35 [162,] 34 36 > (table1 <- table(z[,cat1],z[,cat2])) 22 23 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 27 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 28 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 29 0 0 0 0 0 1 2 1 0 1 0 0 0 0 0 0 0 0 30 0 0 1 1 0 0 0 0 0 2 3 0 0 0 0 0 0 0 31 0 1 1 1 0 0 1 0 3 0 2 1 0 1 0 0 0 0 32 0 0 1 2 1 1 1 2 6 2 1 1 1 1 0 0 1 0 33 0 0 0 0 0 0 3 0 2 2 1 3 3 0 1 1 0 0 34 0 0 1 0 0 1 2 1 2 0 2 2 2 2 1 1 0 0 35 0 0 0 0 1 0 1 1 3 3 0 0 3 0 1 0 1 0 36 0 0 0 0 0 0 0 3 1 1 4 1 1 1 0 0 0 0 37 0 0 1 0 0 0 1 3 1 2 3 1 1 4 1 0 0 0 38 0 0 0 1 0 0 1 2 0 1 2 3 0 1 4 0 1 0 39 0 0 0 0 0 1 1 3 0 1 0 1 0 3 0 1 0 0 40 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 41 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 42 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 43 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 > (V1<-dimnames(y)[[1]][cat1]) [1] "Connected" > (V2<-dimnames(y)[[1]][cat2]) [1] "Separate" > postscript(file="/var/wessaorg/rcomp/tmp/1f9l31321433107.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/2aef81321433107.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 447.1938, df = 289, p-value = 6.509e-09 Warning message: In chisq.test(table1, simulate.p.value = simulate.p.value) : Chi-squared approximation may be incorrect > 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/3dmz71321433107.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/4xu6f1321433107.tab") > > try(system("convert tmp/1f9l31321433107.ps tmp/1f9l31321433107.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.112 0.153 3.415