R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(13 + ,12 + ,14 + ,12 + ,53 + ,16 + ,11 + ,18 + ,11 + ,86 + ,19 + ,15 + ,11 + ,14 + ,66 + ,15 + ,6 + ,12 + ,12 + ,67 + ,14 + ,13 + ,16 + ,21 + ,76 + ,13 + ,10 + ,18 + ,12 + ,78 + ,19 + ,12 + ,14 + ,22 + ,53 + ,15 + ,14 + ,14 + ,11 + ,80 + ,14 + ,12 + ,15 + ,10 + ,74 + ,15 + ,6 + ,15 + ,13 + ,76 + ,16 + ,10 + ,17 + ,10 + ,79 + ,16 + ,12 + ,19 + ,8 + ,54 + ,16 + ,12 + ,10 + ,15 + ,67 + ,16 + ,11 + ,16 + ,14 + ,54 + ,17 + ,15 + ,18 + ,10 + ,87 + ,15 + ,12 + ,14 + ,14 + ,58 + ,15 + ,10 + ,14 + ,14 + ,75 + ,20 + ,12 + ,17 + ,11 + ,88 + ,18 + ,11 + ,14 + ,10 + ,64 + ,16 + ,12 + ,16 + ,13 + ,57 + ,16 + ,11 + ,18 + ,7 + ,66 + ,16 + ,12 + ,11 + ,14 + ,68 + ,19 + ,13 + ,14 + ,12 + ,54 + ,16 + ,11 + ,12 + ,14 + ,56 + ,17 + ,9 + ,17 + ,11 + ,86 + ,17 + ,13 + ,9 + ,9 + ,80 + ,16 + ,10 + ,16 + ,11 + ,76 + ,15 + ,14 + ,14 + ,15 + ,69 + ,16 + ,12 + ,15 + ,14 + ,78 + ,14 + ,10 + ,11 + ,13 + ,67 + ,15 + ,12 + ,16 + ,9 + ,80 + ,12 + ,8 + ,13 + ,15 + ,54 + ,14 + ,10 + ,17 + ,10 + ,71 + ,16 + ,12 + ,15 + ,11 + ,84 + ,14 + ,12 + ,14 + ,13 + ,74 + ,7 + ,7 + ,16 + ,8 + ,71 + ,10 + ,6 + ,9 + ,20 + ,63 + ,14 + ,12 + ,15 + ,12 + ,71 + ,16 + ,10 + ,17 + ,10 + ,76 + ,16 + ,10 + ,13 + ,10 + ,69 + ,16 + ,10 + ,15 + ,9 + ,74 + ,14 + ,12 + ,16 + ,14 + ,75 + ,20 + ,15 + ,16 + ,8 + ,54 + ,14 + ,10 + ,12 + ,14 + ,52 + ,14 + ,10 + ,12 + ,11 + ,69 + ,11 + ,12 + ,11 + ,13 + ,68 + ,14 + ,13 + ,15 + ,9 + ,65 + ,15 + ,11 + ,15 + ,11 + ,75 + ,16 + ,11 + ,17 + ,15 + ,74 + ,14 + ,12 + ,13 + ,11 + ,75 + ,16 + ,14 + ,16 + ,10 + ,72 + ,14 + ,10 + ,14 + ,14 + ,67 + ,12 + ,12 + ,11 + ,18 + ,63 + ,16 + ,13 + ,12 + ,14 + ,62 + ,9 + ,5 + ,12 + ,11 + ,63 + ,14 + ,6 + ,15 + ,12 + ,76 + ,16 + ,12 + ,16 + ,13 + ,74 + ,16 + ,12 + ,15 + ,9 + ,67 + ,15 + ,11 + ,12 + ,10 + ,73 + ,16 + ,10 + ,12 + ,15 + ,70 + ,12 + ,7 + ,8 + ,20 + ,53 + ,16 + ,12 + ,13 + ,12 + ,77 + ,16 + ,14 + ,11 + ,12 + ,77 + ,14 + ,11 + ,14 + ,14 + ,52 + ,16 + ,12 + ,15 + ,13 + ,54 + ,17 + ,13 + ,10 + ,11 + ,80 + ,18 + ,14 + ,11 + ,17 + ,66 + ,18 + ,11 + ,12 + ,12 + ,73 + ,12 + ,12 + ,15 + ,13 + ,63 + ,16 + ,12 + ,15 + ,14 + ,69 + ,10 + ,8 + ,14 + ,13 + ,67 + ,14 + ,11 + ,16 + ,15 + ,54 + ,18 + ,14 + ,15 + ,13 + ,81 + ,18 + ,14 + ,15 + ,10 + ,69 + ,16 + ,12 + ,13 + ,11 + ,84 + ,17 + ,9 + ,12 + ,19 + ,80 + ,16 + ,13 + ,17 + ,13 + ,70 + ,16 + ,11 + ,13 + ,17 + ,69 + ,13 + ,12 + ,15 + ,13 + ,77 + ,16 + ,12 + ,13 + ,9 + ,54 + ,16 + ,12 + ,15 + ,11 + ,79 + ,20 + ,12 + ,16 + ,10 + ,30 + ,16 + ,12 + ,15 + ,9 + ,71 + ,15 + ,12 + ,16 + ,12 + ,73 + ,15 + ,11 + ,15 + ,12 + ,72 + ,16 + ,10 + ,14 + ,13 + ,77 + ,14 + ,9 + ,15 + ,13 + ,75 + ,16 + ,12 + ,14 + ,12 + ,69 + ,16 + ,12 + ,13 + ,15 + ,54 + ,15 + ,12 + ,7 + ,22 + ,70 + ,12 + ,9 + ,17 + ,13 + ,73 + ,17 + ,15 + ,13 + ,15 + ,54 + ,16 + ,12 + ,15 + ,13 + ,77 + ,15 + ,12 + ,14 + ,15 + ,82 + ,13 + ,12 + ,13 + ,10 + ,80 + ,16 + ,10 + ,16 + ,11 + ,80 + ,16 + ,13 + ,12 + ,16 + ,69 + ,16 + ,9 + ,14 + ,11 + ,78 + ,16 + ,12 + ,17 + ,11 + ,81 + ,14 + ,10 + ,15 + ,10 + ,76 + ,16 + ,14 + ,17 + ,10 + ,76 + ,16 + ,11 + ,12 + ,16 + ,73 + ,20 + ,15 + ,16 + ,12 + ,85 + ,15 + ,11 + ,11 + ,11 + ,66 + ,16 + ,11 + ,15 + ,16 + ,79 + ,13 + ,12 + ,9 + ,19 + ,68 + ,17 + ,12 + ,16 + ,11 + ,76 + ,16 + ,12 + ,15 + ,16 + ,71 + ,16 + ,11 + ,10 + ,15 + ,54 + ,12 + ,7 + ,10 + ,24 + ,46 + ,16 + ,12 + ,15 + ,14 + ,82 + ,16 + ,14 + ,11 + ,15 + ,74 + ,17 + ,11 + ,13 + ,11 + ,88 + ,13 + ,11 + ,14 + ,15 + ,38 + ,12 + ,10 + ,18 + ,12 + ,76 + ,18 + ,13 + ,16 + ,10 + ,86 + ,14 + ,13 + ,14 + ,14 + ,54 + ,14 + ,8 + ,14 + ,13 + ,70 + ,13 + ,11 + ,14 + ,9 + ,69 + ,16 + ,12 + ,14 + ,15 + ,90 + ,13 + ,11 + ,12 + ,15 + ,54 + ,16 + ,13 + ,14 + ,14 + ,76 + ,13 + ,12 + ,15 + ,11 + ,89 + ,16 + ,14 + ,15 + ,8 + ,76 + ,15 + ,13 + ,15 + ,11 + ,73 + ,16 + ,15 + ,13 + ,11 + ,79 + ,15 + ,10 + ,17 + ,8 + ,90 + ,17 + ,11 + ,17 + ,10 + ,74 + ,15 + ,9 + ,19 + ,11 + ,81 + ,12 + ,11 + ,15 + ,13 + ,72 + ,16 + ,10 + ,13 + ,11 + ,71 + ,10 + ,11 + ,9 + ,20 + ,66 + ,16 + ,8 + ,15 + ,10 + ,77 + ,12 + ,11 + ,15 + ,15 + ,65 + ,14 + ,12 + ,15 + ,12 + ,74 + ,15 + ,12 + ,16 + ,14 + ,82 + ,13 + ,9 + ,11 + ,23 + ,54 + ,15 + ,11 + ,14 + ,14 + ,63 + ,11 + ,10 + ,11 + ,16 + ,54 + ,12 + ,8 + ,15 + ,11 + ,64 + ,8 + ,9 + ,13 + ,12 + ,69 + ,16 + ,8 + ,15 + ,10 + ,54 + ,15 + ,9 + ,16 + ,14 + ,84 + ,17 + ,15 + ,14 + ,12 + ,86 + ,16 + ,11 + ,15 + ,12 + ,77 + ,10 + ,8 + ,16 + ,11 + ,89 + ,18 + ,13 + ,16 + ,12 + ,76 + ,13 + ,12 + ,11 + ,13 + ,60 + ,16 + ,12 + ,12 + ,11 + ,75 + ,13 + ,9 + ,9 + ,19 + ,73 + ,10 + ,7 + ,16 + ,12 + ,85 + ,15 + ,13 + ,13 + ,17 + ,79 + ,16 + ,9 + ,16 + ,9 + ,71 + ,16 + ,6 + ,12 + ,12 + ,72 + ,14 + ,8 + ,9 + ,19 + ,69 + ,10 + ,8 + ,13 + ,18 + ,78 + ,17 + ,15 + ,13 + ,15 + ,54 + ,13 + ,6 + ,14 + ,14 + ,69 + ,15 + ,9 + ,19 + ,11 + ,81 + ,16 + ,11 + ,13 + ,9 + ,84 + ,12 + ,8 + ,12 + ,18 + ,84 + ,13 + ,8 + ,13 + ,16 + ,69) + ,dim=c(5 + ,162) + ,dimnames=list(c('Learning' + ,'Software' + ,'Happiness' + ,'Depression' + ,'Belonging') + ,1:162)) > y <- array(NA,dim=c(5,162),dimnames=list(c('Learning','Software','Happiness','Depression','Belonging'),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 = '4' > par1 = '3' > 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,] 13 12 14 12 53 [2,] 16 11 18 11 86 [3,] 19 15 11 14 66 [4,] 15 6 12 12 67 [5,] 14 13 16 21 76 [6,] 13 10 18 12 78 [7,] 19 12 14 22 53 [8,] 15 14 14 11 80 [9,] 14 12 15 10 74 [10,] 15 6 15 13 76 [11,] 16 10 17 10 79 [12,] 16 12 19 8 54 [13,] 16 12 10 15 67 [14,] 16 11 16 14 54 [15,] 17 15 18 10 87 [16,] 15 12 14 14 58 [17,] 15 10 14 14 75 [18,] 20 12 17 11 88 [19,] 18 11 14 10 64 [20,] 16 12 16 13 57 [21,] 16 11 18 7 66 [22,] 16 12 11 14 68 [23,] 19 13 14 12 54 [24,] 16 11 12 14 56 [25,] 17 9 17 11 86 [26,] 17 13 9 9 80 [27,] 16 10 16 11 76 [28,] 15 14 14 15 69 [29,] 16 12 15 14 78 [30,] 14 10 11 13 67 [31,] 15 12 16 9 80 [32,] 12 8 13 15 54 [33,] 14 10 17 10 71 [34,] 16 12 15 11 84 [35,] 14 12 14 13 74 [36,] 7 7 16 8 71 [37,] 10 6 9 20 63 [38,] 14 12 15 12 71 [39,] 16 10 17 10 76 [40,] 16 10 13 10 69 [41,] 16 10 15 9 74 [42,] 14 12 16 14 75 [43,] 20 15 16 8 54 [44,] 14 10 12 14 52 [45,] 14 10 12 11 69 [46,] 11 12 11 13 68 [47,] 14 13 15 9 65 [48,] 15 11 15 11 75 [49,] 16 11 17 15 74 [50,] 14 12 13 11 75 [51,] 16 14 16 10 72 [52,] 14 10 14 14 67 [53,] 12 12 11 18 63 [54,] 16 13 12 14 62 [55,] 9 5 12 11 63 [56,] 14 6 15 12 76 [57,] 16 12 16 13 74 [58,] 16 12 15 9 67 [59,] 15 11 12 10 73 [60,] 16 10 12 15 70 [61,] 12 7 8 20 53 [62,] 16 12 13 12 77 [63,] 16 14 11 12 77 [64,] 14 11 14 14 52 [65,] 16 12 15 13 54 [66,] 17 13 10 11 80 [67,] 18 14 11 17 66 [68,] 18 11 12 12 73 [69,] 12 12 15 13 63 [70,] 16 12 15 14 69 [71,] 10 8 14 13 67 [72,] 14 11 16 15 54 [73,] 18 14 15 13 81 [74,] 18 14 15 10 69 [75,] 16 12 13 11 84 [76,] 17 9 12 19 80 [77,] 16 13 17 13 70 [78,] 16 11 13 17 69 [79,] 13 12 15 13 77 [80,] 16 12 13 9 54 [81,] 16 12 15 11 79 [82,] 20 12 16 10 30 [83,] 16 12 15 9 71 [84,] 15 12 16 12 73 [85,] 15 11 15 12 72 [86,] 16 10 14 13 77 [87,] 14 9 15 13 75 [88,] 16 12 14 12 69 [89,] 16 12 13 15 54 [90,] 15 12 7 22 70 [91,] 12 9 17 13 73 [92,] 17 15 13 15 54 [93,] 16 12 15 13 77 [94,] 15 12 14 15 82 [95,] 13 12 13 10 80 [96,] 16 10 16 11 80 [97,] 16 13 12 16 69 [98,] 16 9 14 11 78 [99,] 16 12 17 11 81 [100,] 14 10 15 10 76 [101,] 16 14 17 10 76 [102,] 16 11 12 16 73 [103,] 20 15 16 12 85 [104,] 15 11 11 11 66 [105,] 16 11 15 16 79 [106,] 13 12 9 19 68 [107,] 17 12 16 11 76 [108,] 16 12 15 16 71 [109,] 16 11 10 15 54 [110,] 12 7 10 24 46 [111,] 16 12 15 14 82 [112,] 16 14 11 15 74 [113,] 17 11 13 11 88 [114,] 13 11 14 15 38 [115,] 12 10 18 12 76 [116,] 18 13 16 10 86 [117,] 14 13 14 14 54 [118,] 14 8 14 13 70 [119,] 13 11 14 9 69 [120,] 16 12 14 15 90 [121,] 13 11 12 15 54 [122,] 16 13 14 14 76 [123,] 13 12 15 11 89 [124,] 16 14 15 8 76 [125,] 15 13 15 11 73 [126,] 16 15 13 11 79 [127,] 15 10 17 8 90 [128,] 17 11 17 10 74 [129,] 15 9 19 11 81 [130,] 12 11 15 13 72 [131,] 16 10 13 11 71 [132,] 10 11 9 20 66 [133,] 16 8 15 10 77 [134,] 12 11 15 15 65 [135,] 14 12 15 12 74 [136,] 15 12 16 14 82 [137,] 13 9 11 23 54 [138,] 15 11 14 14 63 [139,] 11 10 11 16 54 [140,] 12 8 15 11 64 [141,] 8 9 13 12 69 [142,] 16 8 15 10 54 [143,] 15 9 16 14 84 [144,] 17 15 14 12 86 [145,] 16 11 15 12 77 [146,] 10 8 16 11 89 [147,] 18 13 16 12 76 [148,] 13 12 11 13 60 [149,] 16 12 12 11 75 [150,] 13 9 9 19 73 [151,] 10 7 16 12 85 [152,] 15 13 13 17 79 [153,] 16 9 16 9 71 [154,] 16 6 12 12 72 [155,] 14 8 9 19 69 [156,] 10 8 13 18 78 [157,] 17 15 13 15 54 [158,] 13 6 14 14 69 [159,] 15 9 19 11 81 [160,] 16 11 13 9 84 [161,] 12 8 12 18 84 [162,] 13 8 13 16 69 > (table1 <- table(z[,cat1],z[,cat2])) 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 9 0 0 1 0 0 0 0 0 0 0 0 0 3 2 0 0 0 0 10 0 0 0 0 1 0 0 0 2 0 0 0 0 0 0 0 0 1 11 0 0 0 0 1 1 3 2 1 1 1 1 0 0 0 0 1 0 12 0 0 0 1 3 3 0 3 2 2 0 1 1 0 0 0 0 0 13 0 0 2 2 5 2 0 0 4 1 2 1 0 0 0 0 0 0 14 0 0 1 1 2 4 4 8 4 0 0 0 0 0 0 1 0 0 15 0 1 4 5 6 5 8 3 1 2 0 0 0 0 0 0 0 0 16 0 2 2 3 4 4 2 4 1 0 0 0 0 0 1 0 0 0 17 0 1 0 5 3 0 2 0 1 0 0 0 0 0 0 0 0 0 18 1 0 0 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 19 0 1 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 > (V1<-dimnames(y)[[1]][cat1]) [1] "Happiness" > (V2<-dimnames(y)[[1]][cat2]) [1] "Depression" > postscript(file="/var/wessaorg/rcomp/tmp/19yaa1321432239.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/2jt421321432239.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 442.4732, df = 204, p-value < 2.2e-16 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=='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/3i1k01321432239.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/4mlkh1321432239.tab") > > try(system("convert tmp/19yaa1321432239.ps tmp/19yaa1321432239.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.800 0.177 3.259