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