R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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('Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'Treatment' + ,'Yes' + ,'Treatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'Yes' + ,'NoTreatment' + ,'No' + ,'NoTreatment' + ,'No') + ,dim=c(2 + ,86) + ,dimnames=list(c('T40' + ,'CorrectAnlysisT40') + ,1:86)) > y <- array(NA,dim=c(2,86),dimnames=list(c('T40','CorrectAnlysisT40'),1:86)) > 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' > par3 <- 'Exact Pearson Chi-Squared by Simulation' > par2 <- '2' > par1 <- '1' > #'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,] "Treatment" "No" [2,] "NoTreatment" "No" [3,] "NoTreatment" "No" [4,] "NoTreatment" "No" [5,] "NoTreatment" "No" [6,] "NoTreatment" "No" [7,] "NoTreatment" "No" [8,] "Treatment" "No" [9,] "NoTreatment" "No" [10,] "NoTreatment" "No" [11,] "Treatment" "No" [12,] "NoTreatment" "No" [13,] "NoTreatment" "No" [14,] "Treatment" "No" [15,] "NoTreatment" "No" [16,] "Treatment" "No" [17,] "Treatment" "Yes" [18,] "Treatment" "No" [19,] "NoTreatment" "No" [20,] "Treatment" "Yes" [21,] "NoTreatment" "No" [22,] "NoTreatment" "No" [23,] "NoTreatment" "No" [24,] "NoTreatment" "No" [25,] "Treatment" "No" [26,] "NoTreatment" "No" [27,] "NoTreatment" "No" [28,] "NoTreatment" "No" [29,] "NoTreatment" "No" [30,] "NoTreatment" "No" [31,] "NoTreatment" "No" [32,] "NoTreatment" "No" [33,] "NoTreatment" "No" [34,] "Treatment" "No" [35,] "NoTreatment" "No" [36,] "NoTreatment" "No" [37,] "Treatment" "No" [38,] "NoTreatment" "No" [39,] "NoTreatment" "No" [40,] "Treatment" "No" [41,] "NoTreatment" "Yes" [42,] "NoTreatment" "No" [43,] "NoTreatment" "No" [44,] "Treatment" "No" [45,] "NoTreatment" "No" [46,] "NoTreatment" "No" [47,] "NoTreatment" "No" [48,] "NoTreatment" "No" [49,] "NoTreatment" "No" [50,] "NoTreatment" "No" [51,] "Treatment" "No" [52,] "Treatment" "Yes" [53,] "NoTreatment" "No" [54,] "NoTreatment" "Yes" [55,] "NoTreatment" "No" [56,] "Treatment" "No" [57,] "NoTreatment" "No" [58,] "NoTreatment" "No" [59,] "NoTreatment" "No" [60,] "Treatment" "Yes" [61,] "Treatment" "No" [62,] "NoTreatment" "No" [63,] "NoTreatment" "No" [64,] "Treatment" "No" [65,] "NoTreatment" "No" [66,] "NoTreatment" "No" [67,] "Treatment" "Yes" [68,] "NoTreatment" "No" [69,] "NoTreatment" "No" [70,] "NoTreatment" "No" [71,] "NoTreatment" "No" [72,] "NoTreatment" "No" [73,] "NoTreatment" "No" [74,] "NoTreatment" "No" [75,] "NoTreatment" "No" [76,] "Treatment" "No" [77,] "NoTreatment" "No" [78,] "NoTreatment" "No" [79,] "Treatment" "Yes" [80,] "Treatment" "No" [81,] "NoTreatment" "No" [82,] "NoTreatment" "No" [83,] "NoTreatment" "No" [84,] "NoTreatment" "Yes" [85,] "NoTreatment" "No" [86,] "NoTreatment" "No" > (table1 <- table(z[,cat1],z[,cat2])) No Yes NoTreatment 60 3 Treatment 17 6 > (V1<-dimnames(y)[[1]][cat1]) [1] "T40" > (V2<-dimnames(y)[[1]][cat2]) [1] "CorrectAnlysisT40" > postscript(file="/var/wessaorg/rcomp/tmp/1sfbi1355917242.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/2vuag1355917242.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 = 8.1774, df = NA, p-value = 0.009495 > if (par3 == 'McNemar Chi-Squared') { + (cst <- mcnemar.test(table1)) + } > if (par3=='Fisher Exact Test') { + (cst <- fisher.test(table1)) + } > if ((par3 != 'McNemar Chi-Squared') & (par3 != 'Fisher Exact Test')) { + 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/wessaorg/rcomp/tmp/3grjl1355917242.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) > if (par3=='Pearson Chi-Squared') a<-table.element(a, 'Pearson Chi Square Statistic', 1, TRUE) > if (par3=='Exact Pearson Chi-Squared by Simulation') a<-table.element(a, 'Exact Pearson Chi Square Statistic', 1, TRUE) > if (par3=='McNemar Chi-Squared') a<-table.element(a, 'McNemar Chi Square Statistic', 1, TRUE) > if (par3=='Fisher Exact Test') a<-table.element(a, 'Odds Ratio', 1, TRUE) > if (par3=='Fisher Exact Test') { + if ((ncol(table1) == 2) & (nrow(table1) == 2)) { + a<-table.element(a, round(cst$estimate, digits=2), 1,FALSE) + } else { + a<-table.element(a, '--', 1,FALSE) + } + } else { + a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE) + } > a<-table.row.end(a) > if(!simulate.p.value){ + if(par3!='Fisher Exact Test') { + 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/wessaorg/rcomp/tmp/4e3h51355917242.tab") > > try(system("convert tmp/1sfbi1355917242.ps tmp/1sfbi1355917242.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.444 0.160 1.574