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(4,4,5,4,2,4,4,4,2,4,4,3,4,4,4,5,5,3,5,3,5,3,3,4,4,4,4,4,5,4,5,4,2,4,4,5,5,5,4,3,5,4,2,2,4,3,4,4,3,5,5,4,5,4,3,4,4,2,4,4,3,3,2,4,4,2,4,3,4,2,4,3,4,4,4,3,3,2,4,4,4,4,4,4,4,4,3,3,4,4,4,4,4,4,3,3,4,4,4,4,4,4,4,3,2,4,2,5,4,4,3,4,3,4,2,4,4,4,4,4,4,4,4,3,4,5,4,3,3,4,4,4,4,4,4,4,4,4,4,4,5,3,3,4,4,4,5,5,4,4,5,4,5,3,4,4,4,2,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,3,2,4,4,4,4,3,5,4,4,2,4,4,2,5,5,4,4,4,3,4,4,4,3,3,4,4,5,5,5,4,4,4,4,5,5,4,4,5,4,4,2,4,5,4,2,3,4,4,3,4,4,4,5,5,4,4,3,4,4,3,5,4,5,4,5,3,2,4,4,4,3,4,4,3,4,4,3,5,5,2,4,4,3,5,3,4,2,4,5,4,2,5,4,4,3,4,2,4,4,4,2,2,3,3,4,3,2,4,2,3,3,5,4,4,5,3,4,4,4,4,2,4,4,4,4,5,5,4,4,4,4,4,3,4,4,3,5,4,4,2,4,4,4,4,2,4,5),dim=c(2,162),dimnames=list(c('opinion','knowing '),1:162)) > y <- array(NA,dim=c(2,162),dimnames=list(c('opinion','knowing '),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 = 'Pearson Chi-Squared' > 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,] 4 4 [2,] 5 4 [3,] 2 4 [4,] 4 4 [5,] 2 4 [6,] 4 3 [7,] 4 4 [8,] 4 5 [9,] 5 3 [10,] 5 3 [11,] 5 3 [12,] 3 4 [13,] 4 4 [14,] 4 4 [15,] 5 4 [16,] 5 4 [17,] 2 4 [18,] 4 5 [19,] 5 5 [20,] 4 3 [21,] 5 4 [22,] 2 2 [23,] 4 3 [24,] 4 4 [25,] 3 5 [26,] 5 4 [27,] 5 4 [28,] 3 4 [29,] 4 2 [30,] 4 4 [31,] 3 3 [32,] 2 4 [33,] 4 2 [34,] 4 3 [35,] 4 2 [36,] 4 3 [37,] 4 4 [38,] 4 3 [39,] 3 2 [40,] 4 4 [41,] 4 4 [42,] 4 4 [43,] 4 4 [44,] 3 3 [45,] 4 4 [46,] 4 4 [47,] 4 4 [48,] 3 3 [49,] 4 4 [50,] 4 4 [51,] 4 4 [52,] 4 3 [53,] 2 4 [54,] 2 5 [55,] 4 4 [56,] 3 4 [57,] 3 4 [58,] 2 4 [59,] 4 4 [60,] 4 4 [61,] 4 4 [62,] 4 3 [63,] 4 5 [64,] 4 3 [65,] 3 4 [66,] 4 4 [67,] 4 4 [68,] 4 4 [69,] 4 4 [70,] 4 4 [71,] 5 3 [72,] 3 4 [73,] 4 4 [74,] 5 5 [75,] 4 4 [76,] 5 4 [77,] 5 3 [78,] 4 4 [79,] 4 2 [80,] 5 4 [81,] 4 4 [82,] 4 4 [83,] 4 4 [84,] 4 4 [85,] 4 4 [86,] 4 4 [87,] 4 4 [88,] 3 4 [89,] 3 2 [90,] 4 4 [91,] 4 4 [92,] 3 5 [93,] 4 4 [94,] 2 4 [95,] 4 2 [96,] 5 5 [97,] 4 4 [98,] 4 3 [99,] 4 4 [100,] 4 3 [101,] 3 4 [102,] 4 5 [103,] 5 5 [104,] 4 4 [105,] 4 4 [106,] 5 5 [107,] 4 4 [108,] 5 4 [109,] 4 2 [110,] 4 5 [111,] 4 2 [112,] 3 4 [113,] 4 3 [114,] 4 4 [115,] 4 5 [116,] 5 4 [117,] 4 3 [118,] 4 4 [119,] 3 5 [120,] 4 5 [121,] 4 5 [122,] 3 2 [123,] 4 4 [124,] 4 3 [125,] 4 4 [126,] 3 4 [127,] 4 3 [128,] 5 5 [129,] 2 4 [130,] 4 3 [131,] 5 3 [132,] 4 2 [133,] 4 5 [134,] 4 2 [135,] 5 4 [136,] 4 3 [137,] 4 2 [138,] 4 4 [139,] 4 2 [140,] 2 3 [141,] 3 4 [142,] 3 2 [143,] 4 2 [144,] 3 3 [145,] 5 4 [146,] 4 5 [147,] 3 4 [148,] 4 4 [149,] 4 2 [150,] 4 4 [151,] 4 4 [152,] 5 5 [153,] 4 4 [154,] 4 4 [155,] 4 3 [156,] 4 4 [157,] 3 5 [158,] 4 4 [159,] 2 4 [160,] 4 4 [161,] 4 2 [162,] 4 5 > (table1 <- table(z[,cat1],z[,cat2])) 2 3 4 5 2 1 1 9 1 3 4 4 12 4 4 14 18 58 11 5 0 6 12 7 > (V1<-dimnames(y)[[1]][cat1]) [1] "opinion" > (V2<-dimnames(y)[[1]][cat2]) [1] "knowing\r" > postscript(file="/var/www/html/rcomp/tmp/1kl9k1290521687.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/2o4pq1290521687.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 10.8663, df = 9, p-value = 0.285 Warning message: In chisq.test(table1, simulate.p.value = simulate.p.value) : Chi-squared approximation may be incorrect > 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/32enz1290521687.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/4vnm21290521687.tab") > > try(system("convert tmp/1kl9k1290521687.ps tmp/1kl9k1290521687.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.835 0.180 1.699