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