R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(1,2,1,2,2,2,1,2,1,1,1,1,2,1,1,2,1,1,1,2,1,1,1,2,2,2,1,2,1,1,1,1,1,1,2,2,1,1,1,2,2,2,1,2,1,1,2,1,2,1,1,2,1,1,1,1,2,1,1,1,1,2,1,2,1,1,2,1,1,1,1,2,1,1,2,2,2,1,2,1,1,2,1,1,1,2,2,2,2,1,1,1,1,2,1,2,1,2,1,1,1,1,1,1,2,1,1,2,1,1,2,2,1,2,2,2,1,1,2,2,2,2,2,1,1,1,2,1,1,2,1,2,2,2,1,2,2,2,1,1,1,2,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,2,1,2,2,1,1,1,1,1,2,1,1,1,2,2,1,1,1,2,2,1,1,2,2,2,1,1,1,1,2,1,2,1,1,1,1,1,1,2,2,2,1,2,1,1,2,1,2,2,2,1,1,1,1,1,2,1,1,1,1,1,2,2,1,2,1,2,1,2,2,1,2,2,1,2,2,1,2,2,2,1,2,1,1,2,2,1,1,2,1,1,2,1,1,1,1,2,2,2,1,1,2,1,2,2,1,1,1,2,2,1,2,2,2,1,2,1,1,1,2,2,2,1,1,1,2,1,1,1,2,1,1,2,2,2,2,1,1,1,2,2,2,2,2,1,1),dim=c(2,152),dimnames=list(c('popularity','hands'),1:152)) > y <- array(NA,dim=c(2,152),dimnames=list(c('popularity','hands'),1:152)) > 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,] 1 2 [2,] 1 2 [3,] 2 2 [4,] 1 2 [5,] 1 1 [6,] 1 1 [7,] 2 1 [8,] 1 2 [9,] 1 1 [10,] 1 2 [11,] 1 1 [12,] 1 2 [13,] 2 2 [14,] 1 2 [15,] 1 1 [16,] 1 1 [17,] 1 1 [18,] 2 2 [19,] 1 1 [20,] 1 2 [21,] 2 2 [22,] 1 2 [23,] 1 1 [24,] 2 1 [25,] 2 1 [26,] 1 2 [27,] 1 1 [28,] 1 1 [29,] 2 1 [30,] 1 1 [31,] 1 2 [32,] 1 2 [33,] 1 1 [34,] 2 1 [35,] 1 1 [36,] 1 2 [37,] 1 1 [38,] 2 2 [39,] 2 1 [40,] 2 1 [41,] 1 2 [42,] 1 1 [43,] 1 2 [44,] 2 2 [45,] 2 1 [46,] 1 1 [47,] 1 2 [48,] 1 2 [49,] 1 2 [50,] 1 1 [51,] 1 1 [52,] 1 1 [53,] 2 1 [54,] 1 2 [55,] 1 1 [56,] 2 2 [57,] 1 2 [58,] 2 2 [59,] 1 1 [60,] 2 2 [61,] 2 2 [62,] 2 1 [63,] 1 1 [64,] 2 1 [65,] 1 2 [66,] 1 2 [67,] 2 2 [68,] 1 2 [69,] 2 2 [70,] 1 1 [71,] 1 2 [72,] 1 1 [73,] 1 1 [74,] 1 1 [75,] 1 2 [76,] 1 1 [77,] 2 1 [78,] 1 2 [79,] 1 1 [80,] 2 1 [81,] 2 2 [82,] 1 1 [83,] 1 1 [84,] 1 2 [85,] 1 1 [86,] 1 2 [87,] 2 1 [88,] 1 1 [89,] 2 2 [90,] 1 1 [91,] 2 2 [92,] 2 1 [93,] 1 1 [94,] 1 2 [95,] 1 2 [96,] 1 1 [97,] 1 1 [98,] 1 1 [99,] 2 2 [100,] 2 1 [101,] 2 1 [102,] 1 2 [103,] 1 2 [104,] 2 2 [105,] 1 1 [106,] 1 1 [107,] 1 2 [108,] 1 1 [109,] 1 1 [110,] 1 2 [111,] 2 1 [112,] 2 1 [113,] 2 1 [114,] 2 2 [115,] 1 2 [116,] 2 1 [117,] 2 2 [118,] 1 2 [119,] 2 2 [120,] 1 2 [121,] 1 1 [122,] 2 2 [123,] 1 1 [124,] 2 1 [125,] 1 2 [126,] 1 1 [127,] 1 1 [128,] 2 2 [129,] 2 1 [130,] 1 2 [131,] 1 2 [132,] 2 1 [133,] 1 1 [134,] 2 2 [135,] 1 2 [136,] 2 2 [137,] 1 2 [138,] 1 1 [139,] 1 2 [140,] 2 2 [141,] 1 1 [142,] 1 2 [143,] 1 1 [144,] 1 2 [145,] 1 1 [146,] 2 2 [147,] 2 2 [148,] 1 1 [149,] 1 2 [150,] 2 2 [151,] 2 2 [152,] 1 1 > (table1 <- table(z[,cat1],z[,cat2])) 1 2 1 53 46 2 24 29 > (V1<-dimnames(y)[[1]][cat1]) [1] "popularity" > (V2<-dimnames(y)[[1]][cat2]) [1] "hands" > postscript(file="/var/www/html/rcomp/tmp/1k2vz1291060050.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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/25kun1291060050.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with Yates' continuity correction data: table1 X-squared = 0.6393, df = 1, p-value = 0.424 > 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/html/rcomp/tmp/393as1291060050.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/html/rcomp/tmp/4ulrg1291060050.tab") > > try(system("convert tmp/1k2vz1291060050.ps tmp/1k2vz1291060050.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.745 0.154 1.484