R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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 + ,2 + ,1 + ,3 + ,1 + ,1 + ,3 + ,1 + ,4 + ,1 + ,2 + ,2 + ,3 + ,3 + ,1 + ,2 + ,1 + ,2 + ,3 + ,2 + ,3 + ,3 + ,3 + ,1 + ,1 + ,2 + ,2 + ,2 + ,4 + ,4 + ,4 + ,1 + ,3 + ,2 + ,1 + ,2 + ,1 + ,2 + ,3 + ,1 + ,1 + ,2 + ,2 + ,4 + ,2 + ,1 + ,2 + ,2 + ,3 + ,1 + ,1 + ,1 + ,1 + ,4 + ,1 + ,1 + ,1 + ,1 + ,4 + ,2 + ,3 + ,2 + ,3 + ,3 + ,1 + ,2 + ,2 + ,3 + ,3 + ,1 + ,1 + ,2 + ,2 + ,4 + ,1 + ,2 + ,1 + ,3 + ,3 + ,1 + ,2 + ,2 + ,1 + ,3 + ,1 + ,1 + ,2 + ,1 + ,4 + ,1 + ,1 + ,2 + ,2 + ,4 + ,2 + ,1 + ,1 + ,1 + ,3 + ,2 + ,2 + ,1 + ,2 + ,3 + ,1 + ,2 + ,2 + ,2 + ,3 + ,2 + ,2 + ,2 + ,2 + ,4 + ,1 + ,1 + ,1 + ,1 + ,3 + ,1 + ,1 + ,1 + ,2 + ,4 + ,1 + ,1 + ,2 + ,2 + ,4 + ,2 + ,1 + ,2 + ,3 + ,3 + ,1 + ,2 + ,3 + ,3 + ,4 + ,1 + ,2 + ,1 + ,1 + ,3 + ,1 + ,1 + ,1 + ,2 + ,4 + ,2 + ,2 + ,3 + ,1 + ,3 + ,1 + ,2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,2 + ,1 + ,3 + ,3 + ,1 + ,1 + ,2 + ,1 + ,3 + ,1 + ,1 + ,2 + ,2 + ,4 + ,1 + ,1 + ,1 + ,2 + ,4 + ,2 + ,2 + ,3 + ,3 + ,3 + ,1 + ,3 + ,3 + ,4 + ,4) + ,dim=c(5 + ,160) + ,dimnames=list(c('depressed' + ,'sad' + ,'effort' + ,'trouble' + ,'enjoying ') + ,1:160)) > y <- array(NA,dim=c(5,160),dimnames=list(c('depressed','sad','effort','trouble','enjoying '),1:160)) > 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 = '5' > 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] [,3] [,4] [,5] [1,] 1 2 2 1 3 [2,] 1 1 3 1 4 [3,] 1 2 2 3 3 [4,] 1 2 1 2 3 [5,] 2 3 3 3 1 [6,] 1 2 2 2 4 [7,] 4 4 1 3 2 [8,] 1 2 1 2 3 [9,] 1 1 2 2 4 [10,] 2 1 2 2 3 [11,] 1 1 1 1 4 [12,] 1 1 1 1 4 [13,] 2 3 2 3 3 [14,] 1 2 2 3 3 [15,] 1 1 2 2 4 [16,] 1 2 1 3 3 [17,] 1 2 2 1 3 [18,] 1 1 2 1 4 [19,] 1 1 2 2 4 [20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 2 3 3 2 [89,] 3 3 3 4 3 [90,] 1 2 2 1 4 [91,] 1 2 1 3 3 [92,] 1 2 1 1 3 [93,] 1 2 2 2 2 [94,] 1 2 1 1 4 [95,] 1 2 2 3 3 [96,] 1 1 2 2 4 [97,] 1 2 2 2 4 [98,] 1 2 1 2 4 [99,] 1 2 1 2 4 [100,] 2 2 3 2 4 [101,] 1 1 2 2 3 [102,] 1 1 1 1 4 [103,] 1 2 3 2 4 [104,] 2 3 2 3 3 [105,] 1 1 2 2 4 [106,] 2 2 3 2 2 [107,] 2 2 2 1 2 [108,] 3 3 3 4 2 [109,] 2 2 2 2 3 [110,] 2 2 2 2 3 [111,] 1 1 1 1 3 [112,] 1 2 1 2 4 [113,] 1 1 2 2 4 [114,] 1 1 1 3 4 [115,] 1 2 2 2 2 [116,] 1 1 3 4 4 [117,] 1 1 1 2 4 [118,] 1 1 3 4 4 [119,] 2 3 3 1 3 [120,] 1 1 2 2 3 [121,] 1 1 1 2 4 [122,] 1 1 1 1 4 [123,] 1 1 1 1 4 [124,] 1 1 1 1 3 [125,] 1 1 1 1 4 [126,] 1 1 1 1 4 [127,] 1 1 2 2 4 [128,] 1 1 1 2 3 [129,] 2 1 1 1 3 [130,] 2 2 3 3 3 [131,] 1 1 2 2 4 [132,] 1 2 2 2 3 [133,] 1 2 1 3 4 [134,] 1 2 2 3 4 [135,] 4 4 3 2 2 [136,] 1 2 2 2 3 [137,] 2 2 2 2 3 [138,] 1 1 1 2 4 [139,] 1 1 2 2 4 [140,] 1 1 1 1 3 [141,] 1 1 4 1 4 [142,] 1 1 1 3 3 [143,] 1 2 2 2 3 [144,] 1 1 2 2 4 [145,] 1 2 1 3 4 [146,] 1 1 1 3 3 [147,] 1 1 2 1 4 [148,] 2 2 4 3 4 [149,] 1 2 1 2 4 [150,] 2 3 1 1 2 [151,] 1 1 1 1 4 [152,] 1 1 2 2 4 [153,] 3 3 2 2 1 [154,] 1 3 1 3 2 [155,] 1 2 1 3 3 [156,] 1 1 2 1 3 [157,] 1 1 2 2 4 [158,] 1 1 1 2 4 [159,] 2 2 3 3 3 [160,] 1 3 3 4 4 > (table1 <- table(z[,cat1],z[,cat2])) 1 2 3 4 1 0 5 46 73 2 1 7 17 5 3 1 1 1 1 4 0 2 0 0 > (V1<-dimnames(y)[[1]][cat1]) [1] "depressed" > (V2<-dimnames(y)[[1]][cat2]) [1] "enjoying\r" > postscript(file="/var/www/html/freestat/rcomp/tmp/13lyv1290599764.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/2o4x01290599764.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 = 62.8428, df = NA, p-value = 0.0009995 > 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/freestat/rcomp/tmp/3amd61290599764.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/freestat/rcomp/tmp/4oxe71290599765.tab") > > try(system("convert tmp/13lyv1290599764.ps tmp/13lyv1290599764.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.519 0.232 1.563