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