R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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. > source('/home/pw/wessanet/cretab') > > > > myrfcuid = 'q0893053-2019' > > x <- array(list(0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'B'",0,"'S'",1,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'B'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",1,"'S'",0,"'S'",1,"'B'",1,"'S'",0,"'S'",1,"'B'",1,"'B'",1,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",1,"'S'",0,"'S'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",0,"'S'",0,"'S'",1,"'B'",0,"'S'",1,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'S'",1,"'B'",1,"'S'",0,"'S'",1,"'B'",1,"'B'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",1,"'B'",0,"'S'",0,"'S'",1,"'S'",0,"'S'",0,"'S'",0,"'S'",1,"'B'",0,"'S'",1,"'B'",0,"'S'",1,"'B'",1,"'S'",0,"'S'",1,"'B'",0,"'S'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",0,"'S'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",0,"'S'",1,"'B'",1,"'B'",1,"'B'",1,"'B'",1,"'S'",1,"'B'",1,"'B'",1,"'B'",0,"'S'",0,"'S'",0,"'S'",1,"'B'",1,"'B'",1,"'S'",1,"'S'",1,"'B'",1,"'S'",1,"'B'",1,"'B'",0,"'S'",1,"'B'",0,"'S'",0,"'S'",1,"'B'",1,"'B'",0,"'S'",0,"'S'",0,"'S'",0,"'B'",0,"'S'",0,"'S'",1,"'B'",1,"'B'"),dim=c(2,179),dimnames=list(c('spssC','groupC'),1:179)) > y <- array(NA,dim=c(2,179),dimnames=list(c('spssC','groupC'),1:179)) > 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.2.327 (Thu, 22 Sep 2016 16:59:07 +0200) > #Author: root > #To cite this work: Wessa P. (2016), Chi-Squared Test, McNemar Test, and Fisher Exact Test (v1.0.9) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_chi_squared_tests.wasp/ > #Source of accompanying publication: > # > library(vcd) Loading required package: grid > 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,] "0" "'S'" [2,] "0" "'S'" [3,] "0" "'S'" [4,] "0" "'S'" [5,] "0" "'S'" [6,] "0" "'S'" [7,] "0" "'S'" [8,] "0" "'S'" [9,] "0" "'S'" [10,] "1" "'S'" [11,] "0" "'S'" [12,] "0" "'S'" [13,] "0" "'S'" [14,] "0" "'S'" [15,] "0" "'S'" [16,] "1" "'S'" [17,] "0" "'S'" [18,] "0" "'S'" [19,] "0" "'S'" [20,] "1" "'S'" [21,] "0" "'S'" [22,] "0" "'S'" [23,] "0" "'S'" [24,] "0" "'S'" [25,] "1" "'S'" [26,] "0" "'S'" [27,] "0" "'S'" [28,] "0" "'S'" [29,] "0" "'S'" [30,] "0" "'S'" [31,] "1" "'B'" [32,] "0" "'S'" [33,] "1" "'S'" [34,] "1" "'S'" [35,] "0" "'S'" [36,] "0" "'S'" [37,] "0" "'S'" [38,] "0" "'S'" [39,] "0" "'S'" [40,] "0" "'S'" [41,] "0" "'S'" [42,] "0" "'B'" [43,] "0" "'S'" [44,] "0" "'S'" [45,] "0" "'S'" [46,] "0" "'S'" [47,] "0" "'S'" [48,] "0" "'S'" [49,] "1" "'S'" [50,] "0" "'S'" [51,] "0" "'S'" [52,] "0" "'S'" [53,] "0" "'S'" [54,] "0" "'S'" [55,] "1" "'S'" [56,] "1" "'S'" [57,] "0" "'S'" [58,] "1" "'B'" [59,] "1" "'S'" [60,] "0" "'S'" [61,] "1" "'B'" [62,] "1" "'B'" [63,] "1" "'S'" [64,] "0" "'S'" [65,] "1" "'S'" [66,] "0" "'S'" [67,] "0" "'S'" [68,] "0" "'S'" [69,] "1" "'S'" [70,] "1" "'S'" [71,] "0" "'S'" [72,] "1" "'B'" [73,] "1" "'B'" [74,] "1" "'B'" [75,] "1" "'B'" [76,] "1" "'B'" [77,] "1" "'B'" [78,] "1" "'B'" [79,] "0" "'S'" [80,] "0" "'S'" [81,] "1" "'B'" [82,] "0" "'S'" [83,] "1" "'S'" [84,] "1" "'S'" [85,] "0" "'S'" [86,] "0" "'S'" [87,] "0" "'S'" [88,] "1" "'S'" [89,] "1" "'S'" [90,] "0" "'S'" [91,] "0" "'S'" [92,] "0" "'S'" [93,] "0" "'S'" [94,] "0" "'S'" [95,] "1" "'S'" [96,] "0" "'S'" [97,] "0" "'S'" [98,] "0" "'S'" [99,] "0" "'S'" [100,] "1" "'S'" [101,] "0" "'S'" [102,] "0" "'S'" [103,] "0" "'S'" [104,] "1" "'S'" [105,] "1" "'B'" [106,] "1" "'S'" [107,] "0" "'S'" [108,] "1" "'B'" [109,] "1" "'B'" [110,] "0" "'S'" [111,] "1" "'S'" [112,] "0" "'S'" [113,] "0" "'S'" [114,] "1" "'S'" [115,] "0" "'S'" [116,] "0" "'S'" [117,] "1" "'S'" [118,] "0" "'S'" [119,] "1" "'B'" [120,] "0" "'S'" [121,] "0" "'S'" [122,] "1" "'S'" [123,] "0" "'S'" [124,] "0" "'S'" [125,] "0" "'S'" [126,] "1" "'B'" [127,] "0" "'S'" [128,] "1" "'B'" [129,] "0" "'S'" [130,] "1" "'B'" [131,] "1" "'S'" [132,] "0" "'S'" [133,] "1" "'B'" [134,] "0" "'S'" [135,] "1" "'B'" [136,] "1" "'B'" [137,] "1" "'B'" [138,] "1" "'B'" [139,] "0" "'S'" [140,] "1" "'B'" [141,] "1" "'B'" [142,] "1" "'B'" [143,] "1" "'B'" [144,] "1" "'B'" [145,] "1" "'B'" [146,] "0" "'S'" [147,] "1" "'B'" [148,] "1" "'B'" [149,] "1" "'B'" [150,] "1" "'B'" [151,] "1" "'S'" [152,] "1" "'B'" [153,] "1" "'B'" [154,] "1" "'B'" [155,] "0" "'S'" [156,] "0" "'S'" [157,] "0" "'S'" [158,] "1" "'B'" [159,] "1" "'B'" [160,] "1" "'S'" [161,] "1" "'S'" [162,] "1" "'B'" [163,] "1" "'S'" [164,] "1" "'B'" [165,] "1" "'B'" [166,] "0" "'S'" [167,] "1" "'B'" [168,] "0" "'S'" [169,] "0" "'S'" [170,] "1" "'B'" [171,] "1" "'B'" [172,] "0" "'S'" [173,] "0" "'S'" [174,] "0" "'S'" [175,] "0" "'B'" [176,] "0" "'S'" [177,] "0" "'S'" [178,] "1" "'B'" [179,] "1" "'B'" > (table1 <- table(z[,cat1],z[,cat2])) 'B' 'S' 0 2 99 1 47 31 > (V1<-dimnames(y)[[1]][cat1]) [1] "spssC" > (V2<-dimnames(y)[[1]][cat2]) [1] "groupC" > postscript(file="/home/pw/wessanet/rcomp/tmp/12qub1580205390.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 > > 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="/home/pw/wessanet/rcomp/tmp/27mty1580205390.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test with Yates' continuity correction data: table1 X-squared = 72.279, df = 1, p-value < 2.2e-16 > 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="/home/pw/wessanet/rcomp/tmp/3wbm21580205390.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="/home/pw/wessanet/rcomp/tmp/4rx0a1580205390.tab") > > try(system("convert /home/pw/wessanet/rcomp/tmp/12qub1580205390.ps /home/pw/wessanet/rcomp/tmp/12qub1580205390.png",intern=TRUE)) character(0) > > proc.time() user system elapsed 0.503 0.053 0.553