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('C','C','C','C','A','A','C','D','B','B','B','B','C','D','D','D','B','C','B','B','B','B','C','C','B','B','B','C','A','A','B','C','B','B','A','B','B','B','C','C','B','B','A','A','A','A','C','B','B','A','A','A','A','A','A','A','A','A','A','A','A','A','C','B','A','A','A','A','D','C','D','D','D','D','D','D','D','D','D','D','D','D','D','D','D','D','D','D','C','C','C','C','C','D','D','C','D','C','D','D','B','B','C','B','C','B','A','A','B','C'),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) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = 'Exact Pearson Chi-Squared by Simulation' > par2 = '2' > par1 = '1' > ylab = '' > xlab = '' > main = '' > #'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,] "C" "C" [2,] "C" "C" [3,] "A" "A" [4,] "C" "D" [5,] "B" "B" [6,] "B" "B" [7,] "C" "D" [8,] "D" "D" [9,] "B" "C" [10,] "B" "B" [11,] "B" "B" [12,] "C" "C" [13,] "B" "B" [14,] "B" "C" [15,] "A" "A" [16,] "B" "C" [17,] "B" "B" [18,] "A" "B" [19,] "B" "B" [20,] "C" "C" [21,] "B" "B" [22,] "A" "A" [23,] "A" "A" [24,] "C" "B" [25,] "B" "A" [26,] "A" "A" [27,] "A" "A" [28,] "A" "A" [29,] "A" "A" [30,] "A" "A" [31,] "A" "A" [32,] "C" "B" [33,] "A" "A" [34,] "A" "A" [35,] "D" "C" [36,] "D" "D" [37,] "D" "D" [38,] "D" "D" [39,] "D" "D" [40,] "D" "D" [41,] "D" "D" [42,] "D" "D" [43,] "D" "D" [44,] "D" "D" [45,] "C" "C" [46,] "C" "C" [47,] "C" "D" [48,] "D" "C" [49,] "D" "C" [50,] "D" "D" [51,] "B" "B" [52,] "C" "B" [53,] "C" "B" [54,] "A" "A" [55,] "B" "C" > (table1 <- table(z[,cat1],z[,cat2])) A B C D A 13 1 0 0 B 1 9 4 0 C 0 4 6 3 D 0 0 3 11 > (V1<-dimnames(y)[[1]][cat1]) [1] "Uitvoer" > (V2<-dimnames(y)[[1]][cat2]) [1] "Invoer" > postscript(file="/var/www/rcomp/tmp/1yfnl1291754813.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/2cp3c1291754813.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 = 76.4942, 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/rcomp/tmp/3f72i1291754813.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/4jpio1291754813.tab") > > try(system("convert tmp/1yfnl1291754813.ps tmp/1yfnl1291754813.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.790 0.250 1.057