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('Low','Low','Low','Low','High','High','Low','Low','High','High','High','High','Low','Low','Low','Low','High','Low','High','High','High','High','Low','Low','High','High','High','Low','High','High','High','Low','High','High','High','High','High','High','Low','Low','High','High','High','High','High','High','Low','High','High','High','High','High','High','High','High','High','High','High','High','High','High','High','Low','High','High','High','High','High','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','Low','High','High','Low','High','Low','High','High','High','High','Low'),dim=c(2,55),dimnames=list(c('Uitvoer','Invoer'),1:55)) > y <- array(NA,dim=c(2,55),dimnames=list(c('Uitvoer','Invoer'),1:55)) > 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 = 'Exact Pearson Chi-Squared by Simulation' > 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,] "Low" "Low" [2,] "Low" "Low" [3,] "High" "High" [4,] "Low" "Low" [5,] "High" "High" [6,] "High" "High" [7,] "Low" "Low" [8,] "Low" "Low" [9,] "High" "Low" [10,] "High" "High" [11,] "High" "High" [12,] "Low" "Low" [13,] "High" "High" [14,] "High" "Low" [15,] "High" "High" [16,] "High" "Low" [17,] "High" "High" [18,] "High" "High" [19,] "High" "High" [20,] "Low" "Low" [21,] "High" "High" [22,] "High" "High" [23,] "High" "High" [24,] "Low" "High" [25,] "High" "High" [26,] "High" "High" [27,] "High" "High" [28,] "High" "High" [29,] "High" "High" [30,] "High" "High" [31,] "High" "High" [32,] "Low" "High" [33,] "High" "High" [34,] "High" "High" [35,] "Low" "Low" [36,] "Low" "Low" [37,] "Low" "Low" [38,] "Low" "Low" [39,] "Low" "Low" [40,] "Low" "Low" [41,] "Low" "Low" [42,] "Low" "Low" [43,] "Low" "Low" [44,] "Low" "Low" [45,] "Low" "Low" [46,] "Low" "Low" [47,] "Low" "Low" [48,] "Low" "Low" [49,] "Low" "Low" [50,] "Low" "Low" [51,] "High" "High" [52,] "Low" "High" [53,] "Low" "High" [54,] "High" "High" [55,] "High" "Low" > (table1 <- table(z[,cat1],z[,cat2])) High Low High 24 4 Low 4 23 > (V1<-dimnames(y)[[1]][cat1]) [1] "Uitvoer" > (V2<-dimnames(y)[[1]][cat2]) [1] "Invoer" > postscript(file="/var/www/html/rcomp/tmp/1h6rc1291114041.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/2vy7k1291114041.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 = 27.647, df = NA, p-value = 0.0004998 > 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/3zyoq1291114041.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/4khme1291114041.tab") > > try(system("convert tmp/1h6rc1291114041.ps tmp/1h6rc1291114041.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.800 0.197 2.913