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' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'Treatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Good' + ,'Treatment' + ,'Good' + ,'Treatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Bad' + ,'NoTreatment' + ,'Good' + ,'NoTreatment' + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Good' + ,NA + ,'Good' + ,NA + ,'Bad' + ,NA + ,'Bad' + ,NA + ,'Bad') + ,dim=c(2 + ,154) + ,dimnames=list(c('T40' + ,'Outcome') + ,1:154)) > y <- array(NA,dim=c(2,154),dimnames=list(c('T40','Outcome'),1:154)) > 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" "Good" [2,] "NoTreatment" "Bad" [3,] "NoTreatment" "Bad" [4,] "NoTreatment" "Bad" [5,] "NoTreatment" "Bad" [6,] "NoTreatment" "Good" [7,] "NoTreatment" "Bad" [8,] "Treatment" "Bad" [9,] "NoTreatment" "Good" [10,] "NoTreatment" "Bad" [11,] "Treatment" "Bad" [12,] "NoTreatment" "Bad" [13,] "NoTreatment" "Bad" [14,] "Treatment" "Bad" [15,] "NoTreatment" "Good" [16,] "Treatment" "Good" [17,] "Treatment" "Bad" [18,] "Treatment" "Bad" [19,] "NoTreatment" "Good" [20,] "Treatment" "Good" [21,] "NoTreatment" "Bad" [22,] "NoTreatment" "Good" [23,] "NoTreatment" "Good" [24,] "NoTreatment" "Good" [25,] "Treatment" "Good" [26,] "NoTreatment" "Bad" [27,] "NoTreatment" "Good" [28,] "NoTreatment" "Bad" [29,] "NoTreatment" "Good" [30,] "NoTreatment" "Bad" [31,] "NoTreatment" "Bad" [32,] "NoTreatment" "Bad" [33,] "NoTreatment" "Bad" [34,] "Treatment" "Good" [35,] "NoTreatment" "Bad" [36,] "NoTreatment" "Bad" [37,] "Treatment" "Bad" [38,] "NoTreatment" "Good" [39,] "NoTreatment" "Good" [40,] "Treatment" "Bad" [41,] "NoTreatment" "Good" [42,] "NoTreatment" "Good" [43,] "NoTreatment" "Good" [44,] "Treatment" "Bad" [45,] "NoTreatment" "Bad" [46,] "NoTreatment" "Good" [47,] "NoTreatment" "Bad" [48,] "NoTreatment" "Good" [49,] "NoTreatment" "Good" [50,] "NoTreatment" "Bad" [51,] "Treatment" "Bad" [52,] "Treatment" "Bad" [53,] "NoTreatment" "Good" [54,] "NoTreatment" "Bad" [55,] "NoTreatment" "Bad" [56,] "Treatment" "Good" [57,] "NoTreatment" "Good" [58,] "NoTreatment" "Good" [59,] "NoTreatment" "Good" [60,] "Treatment" "Good" [61,] "Treatment" "Good" [62,] "NoTreatment" "Bad" [63,] "NoTreatment" "Bad" [64,] "Treatment" "Good" [65,] "NoTreatment" "Bad" [66,] "NoTreatment" "Bad" [67,] "Treatment" "Bad" [68,] "NoTreatment" "Bad" [69,] "NoTreatment" "Good" [70,] "NoTreatment" "Bad" [71,] "NoTreatment" "Bad" [72,] "NoTreatment" "Good" [73,] "NoTreatment" "Good" [74,] "NoTreatment" "Bad" [75,] "NoTreatment" "Good" [76,] "Treatment" "Good" [77,] "NoTreatment" "Good" [78,] "NoTreatment" "Good" [79,] "Treatment" "Good" [80,] "Treatment" "Bad" [81,] "NoTreatment" "Bad" [82,] "NoTreatment" "Good" [83,] "NoTreatment" "Bad" [84,] "NoTreatment" "Bad" [85,] "NoTreatment" "Good" [86,] "NoTreatment" "Bad" [87,] NA "Good" [88,] NA "Good" [89,] NA "Bad" [90,] NA "Good" [91,] NA "Bad" [92,] NA "Bad" [93,] NA "Bad" [94,] NA "Bad" [95,] NA "Bad" [96,] NA "Good" [97,] NA "Bad" [98,] NA "Bad" [99,] NA "Bad" [100,] NA "Good" [101,] NA "Good" [102,] NA "Bad" [103,] NA "Bad" [104,] NA "Bad" [105,] NA "Bad" [106,] NA "Bad" [107,] NA "Bad" [108,] NA "Bad" [109,] NA "Bad" [110,] NA "Bad" [111,] NA "Bad" [112,] NA "Bad" [113,] NA "Bad" [114,] NA "Bad" [115,] NA "Bad" [116,] NA "Bad" [117,] NA "Good" [118,] NA "Bad" [119,] NA "Bad" [120,] NA "Good" [121,] NA "Bad" [122,] NA "Bad" [123,] NA "Bad" [124,] NA "Good" [125,] NA "Good" [126,] NA "Bad" [127,] NA "Bad" [128,] NA "Good" [129,] NA "Bad" [130,] NA "Good" [131,] NA "Bad" [132,] NA "Good" [133,] NA "Bad" [134,] NA "Bad" [135,] NA "Bad" [136,] NA "Bad" [137,] NA "Good" [138,] NA "Good" [139,] NA "Bad" [140,] NA "Bad" [141,] NA "Good" [142,] NA "Good" [143,] NA "Bad" [144,] NA "Good" [145,] NA "Bad" [146,] NA "Good" [147,] NA "Bad" [148,] NA "Bad" [149,] NA "Bad" [150,] NA "Good" [151,] NA "Good" [152,] NA "Bad" [153,] NA "Bad" [154,] NA "Bad" > (table1 <- table(z[,cat1],z[,cat2])) Bad Good NoTreatment 34 29 Treatment 12 11 > (V1<-dimnames(y)[[1]][cat1]) [1] "T40" > (V2<-dimnames(y)[[1]][cat2]) [1] "Outcome" > postscript(file="/var/wessaorg/rcomp/tmp/1kl621355658615.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/245ho1355658615.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 = 0.0218, df = NA, p-value = 1 > 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/3v1111355658615.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/4ns751355658615.tab") > > try(system("convert tmp/1kl621355658615.ps tmp/1kl621355658615.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.759 0.267 1.969