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(5,3,4,3,4,2,4,2,3,1,4,4,5,2,4,2,3,4,4,5,5,3,4,3,5,2,4,3,4,2,3,3,4,4,4,3,5,2,2,3,4,2,2,2,4,3,4,3,4,2,4,4,4,2,3,3,4,3,4,3,4,1,5,1,3,4,4,3,4,4,4,3,4,3,4,3,3,2,4,2,5,3,4,3,4,4,2,5,4,5,3,3,4,4,4,3,4,3,5,3,2,2,4,3,5,2,4,3,3,2,4,4,4,2,4,2,4,3,4,2,3,3,3,4,3,2,2,2,3,2,3,2,4,2,4,4,4,4,4,4,4,5,3,1,4,3,5,2,4,3,5,5,4,2,4,4,2,2,4,4,4,3,4,3,4,4,4,3,3,2,3,2,4,4,4,2,3,3,4,3,4,1,5,5,5,2,3,2,4,2,5,3,4,3,3,2,4,3,5,3,4,2,5,3,4,2,2,3,3,2,5,4,4,4,5,5,4,4,5,3,3,2,3,2,4,2,3,3,4,4,4,3,4,4,2,4,3,2,5,4,1,3,4,2,4,3,4,3,5,4,2,5,3,5,5,4,2,4,3,4,3,4,3,4,4,4,3,5,3,3,2,3,1,4,4,4,3,3,3,4,3,3,2,4,3,2,1,4,2,4,5,4,2,4,3,4,2,4,3,5,2,5,3,4,4,4,3,5,4,4,3,5,5,4,1,4,2,3,4,4,2,5,3),dim=c(2,162),dimnames=list(c('experience','education '),1:162)) > y <- array(NA,dim=c(2,162),dimnames=list(c('experience','education '),1:162)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > 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,] 5 3 [2,] 4 3 [3,] 4 2 [4,] 4 2 [5,] 3 1 [6,] 4 4 [7,] 5 2 [8,] 4 2 [9,] 3 4 [10,] 4 5 [11,] 5 3 [12,] 4 3 [13,] 5 2 [14,] 4 3 [15,] 4 2 [16,] 3 3 [17,] 4 4 [18,] 4 3 [19,] 5 2 [20,] 2 3 [21,] 4 2 [22,] 2 2 [23,] 4 3 [24,] 4 3 [25,] 4 2 [26,] 4 4 [27,] 4 2 [28,] 3 3 [29,] 4 3 [30,] 4 3 [31,] 4 1 [32,] 5 1 [33,] 3 4 [34,] 4 3 [35,] 4 4 [36,] 4 3 [37,] 4 3 [38,] 4 3 [39,] 3 2 [40,] 4 2 [41,] 5 3 [42,] 4 3 [43,] 4 4 [44,] 2 5 [45,] 4 5 [46,] 3 3 [47,] 4 4 [48,] 4 3 [49,] 4 3 [50,] 5 3 [51,] 2 2 [52,] 4 3 [53,] 5 2 [54,] 4 3 [55,] 3 2 [56,] 4 4 [57,] 4 2 [58,] 4 2 [59,] 4 3 [60,] 4 2 [61,] 3 3 [62,] 3 4 [63,] 3 2 [64,] 2 2 [65,] 3 2 [66,] 3 2 [67,] 4 2 [68,] 4 4 [69,] 4 4 [70,] 4 4 [71,] 4 5 [72,] 3 1 [73,] 4 3 [74,] 5 2 [75,] 4 3 [76,] 5 5 [77,] 4 2 [78,] 4 4 [79,] 2 2 [80,] 4 4 [81,] 4 3 [82,] 4 3 [83,] 4 4 [84,] 4 3 [85,] 3 2 [86,] 3 2 [87,] 4 4 [88,] 4 2 [89,] 3 3 [90,] 4 3 [91,] 4 1 [92,] 5 5 [93,] 5 2 [94,] 3 2 [95,] 4 2 [96,] 5 3 [97,] 4 3 [98,] 3 2 [99,] 4 3 [100,] 5 3 [101,] 4 2 [102,] 5 3 [103,] 4 2 [104,] 2 3 [105,] 3 2 [106,] 5 4 [107,] 4 4 [108,] 5 5 [109,] 4 4 [110,] 5 3 [111,] 3 2 [112,] 3 2 [113,] 4 2 [114,] 3 3 [115,] 4 4 [116,] 4 3 [117,] 4 4 [118,] 2 4 [119,] 3 2 [120,] 5 4 [121,] 1 3 [122,] 4 2 [123,] 4 3 [124,] 4 3 [125,] 5 4 [126,] 2 5 [127,] 3 5 [128,] 5 4 [129,] 2 4 [130,] 3 4 [131,] 3 4 [132,] 3 4 [133,] 4 4 [134,] 3 5 [135,] 3 3 [136,] 2 3 [137,] 1 4 [138,] 4 4 [139,] 3 3 [140,] 3 4 [141,] 3 3 [142,] 2 4 [143,] 3 2 [144,] 1 4 [145,] 2 4 [146,] 5 4 [147,] 2 4 [148,] 3 4 [149,] 2 4 [150,] 3 5 [151,] 2 5 [152,] 3 4 [153,] 4 4 [154,] 3 5 [155,] 4 4 [156,] 3 5 [157,] 5 4 [158,] 1 4 [159,] 2 3 [160,] 4 4 [161,] 2 5 [162,] 3 5 > (table1 <- table(z[,cat1],z[,cat2])) 1 2 3 4 5 1 0 0 1 3 0 2 0 4 4 6 4 3 2 14 9 9 6 4 2 19 29 23 3 5 1 6 8 6 3 > (V1<-dimnames(y)[[1]][cat1]) [1] "experience" > (V2<-dimnames(y)[[1]][cat2]) [1] "education\r" > postscript(file="/var/www/html/rcomp/tmp/197kk1290518721.ps",horizontal=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) Warning message: In grid.Call.graphics("L_text", as.graphicsAnnot(x$label), x$x, : font width unknown for character 0xd > 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/2cpiq1290518721.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 = 17.2207, df = NA, p-value = 0.3728 > 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/3g7zw1290518721.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/4j8gk1290518721.tab") > > try(system("convert tmp/197kk1290518721.ps tmp/197kk1290518721.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.926 0.194 2.106