R version 2.12.0 (2010-10-15) Copyright (C) 2010 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('H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'L' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'H' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'H' + ,'L' + ,'L' + ,'H' + ,'H' + ,'H' + ,'L' + ,'L' + ,'L') + ,dim=c(2 + ,145) + ,dimnames=list(c('Happiness' + ,'DAction') + ,1:145)) > y <- array(NA,dim=c(2,145),dimnames=list(c('Happiness','DAction'),1:145)) > 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,] "H" "L" [2,] "H" "L" [3,] "L" "L" [4,] "L" "H" [5,] "H" "L" [6,] "H" "L" [7,] "H" "H" [8,] "H" "L" [9,] "H" "L" [10,] "H" "H" [11,] "H" "H" [12,] "H" "H" [13,] "L" "H" [14,] "H" "L" [15,] "H" "H" [16,] "H" "L" [17,] "H" "L" [18,] "H" "L" [19,] "H" "H" [20,] "H" "H" [21,] "H" "H" [22,] "L" "H" [23,] "H" "H" [24,] "L" "H" [25,] "H" "H" [26,] "H" "H" [27,] "L" "L" [28,] "H" "L" [29,] "L" "H" [30,] "H" "L" [31,] "H" "L" [32,] "H" "L" [33,] "H" "H" [34,] "L" "H" [35,] "H" "H" [36,] "H" "L" [37,] "L" "H" [38,] "H" "H" [39,] "H" "L" [40,] "H" "L" [41,] "L" "H" [42,] "L" "H" [43,] "H" "L" [44,] "H" "L" [45,] "L" "L" [46,] "H" "H" [47,] "H" "L" [48,] "L" "L" [49,] "L" "H" [50,] "L" "L" [51,] "H" "L" [52,] "H" "L" [53,] "H" "L" [54,] "L" "L" [55,] "L" "L" [56,] "L" "H" [57,] "L" "L" [58,] "L" "L" [59,] "H" "L" [60,] "H" "H" [61,] "L" "H" [62,] "L" "L" [63,] "L" "H" [64,] "H" "H" [65,] "H" "L" [66,] "H" "H" [67,] "H" "H" [68,] "H" "L" [69,] "H" "L" [70,] "L" "L" [71,] "H" "L" [72,] "L" "H" [73,] "H" "H" [74,] "L" "L" [75,] "H" "H" [76,] "H" "L" [77,] "H" "L" [78,] "H" "H" [79,] "H" "H" [80,] "H" "L" [81,] "H" "H" [82,] "L" "H" [83,] "H" "L" [84,] "L" "L" [85,] "H" "H" [86,] "H" "H" [87,] "L" "H" [88,] "H" "L" [89,] "L" "H" [90,] "H" "L" [91,] "H" "L" [92,] "H" "L" [93,] "H" "H" [94,] "L" "H" [95,] "H" "L" [96,] "L" "H" [97,] "H" "H" [98,] "L" "L" [99,] "H" "L" [100,] "L" "H" [101,] "L" "H" [102,] "H" "L" [103,] "L" "H" [104,] "L" "L" [105,] "H" "H" [106,] "H" "L" [107,] "H" "L" [108,] "H" "H" [109,] "H" "H" [110,] "H" "H" [111,] "H" "L" [112,] "L" "H" [113,] "H" "H" [114,] "H" "L" [115,] "H" "L" [116,] "L" "H" [117,] "H" "L" [118,] "H" "L" [119,] "H" "L" [120,] "H" "H" [121,] "L" "H" [122,] "L" "H" [123,] "H" "L" [124,] "H" "L" [125,] "H" "L" [126,] "L" "H" [127,] "H" "H" [128,] "L" "H" [129,] "H" "H" [130,] "L" "H" [131,] "H" "H" [132,] "H" "L" [133,] "H" "H" [134,] "H" "H" [135,] "H" "L" [136,] "L" "H" [137,] "L" "H" [138,] "H" "H" [139,] "L" "H" [140,] "L" "H" [141,] "L" "H" [142,] "L" "L" [143,] "H" "H" [144,] "H" "L" [145,] "L" "L" > (table1 <- table(z[,cat1],z[,cat2])) H L H 41 53 L 34 17 > (V1<-dimnames(y)[[1]][cat1]) [1] "Happiness" > (V2<-dimnames(y)[[1]][cat2]) [1] "DAction" > postscript(file="/var/www/rcomp/tmp/1mgjw1292684731.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/2pyhk1292684731.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with Yates' continuity correction data: table1 X-squared = 6.1417, df = 1, p-value = 0.01320 > if (par3 == 'McNemar Chi-Squared') { + (cst <- mcnemar.test(table1)) + } > if (par3 != 'McNemar Chi-Squared') { + 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/www/rcomp/tmp/3tzg81292684731.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) > a<-table.element(a, 'Chi Square Statistic', 1, TRUE) > a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE) > a<-table.row.end(a) > if(!simulate.p.value){ + 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/www/rcomp/tmp/4ezee1292684731.tab") > > try(system("convert tmp/1mgjw1292684731.ps tmp/1mgjw1292684731.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.84 0.23 1.05