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