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