R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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('Boys' + ,'Often' + ,'Boys' + ,'Not_bul' + ,'Girls' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Both' + ,'Often' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Not_bul' + ,'Girls' + ,'Often' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Often' + ,'Both' + ,'Often' + ,'Both' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Both' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Girls' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Often' + ,'Both' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Girls' + ,'Often' + ,'Girls' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Girls' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Girls' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Girls' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Rarely' + ,'Not_bul' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Both' + ,'Often' + ,'Boys' + ,'Often' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Girls' + ,'Often' + ,'Girls' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Often' + ,'Girls' + ,'Often' + ,'Girls' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Girls' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Rarely' + ,'Girls' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Both' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Girls' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Girls' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Often' + ,'Boys' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Both' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Both' + ,'Often' + ,'Boys' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Boys' + ,'Rarely' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul') + ,dim=c(2 + ,193) + ,dimnames=list(c('gender_of_bully' + ,'how_often_bullied') + ,1:193)) > y <- array(NA,dim=c(2,193),dimnames=list(c('gender_of_bully','how_often_bullied'),1:193)) > 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-Square' > par2 = '2' > par1 = '1' > cat1 <- as.numeric(par1) # > cat2<- as.numeric(par2) # > simulate.p.value=FALSE > if (par3 == 'Exact Pearson Chi Square by simulation') simulate.p.value=TRUE > x <- t(x) > (z <- array(unlist(x),dim=c(length(x[,1]),length(x[1,])))) [,1] [,2] [1,] "Boys" "Often" [2,] "Boys" "Not_bul" [3,] "Girls" "Rarely" [4,] "Boys" "Rarely" [5,] "Not_bul" "Not_bul" [6,] "Boys" "Not_bul" [7,] "Not_bul" "Not_bul" [8,] "Not_bul" "Not_bul" [9,] "Not_bul" "Not_bul" [10,] "Boys" "Rarely" [11,] "Not_bul" "Not_bul" [12,] "Boys" "Often" [13,] "Both" "Often" [14,] "Boys" "Often" [15,] "Not_bul" "Not_bul" [16,] "Not_bul" "Not_bul" [17,] "Boys" "Rarely" [18,] "Boys" "Rarely" [19,] "Boys" "Not_bul" [20,] "Not_bul" "Not_bul" [21,] "Boys" "Rarely" [22,] "Not_bul" "Not_bul" [23,] "Boys" "Not_bul" [24,] "Girls" "Often" [25,] "Boys" "Often" [26,] "Not_bul" "Not_bul" [27,] "Boys" "Not_bul" [28,] "Boys" "Rarely" [29,] "Boys" "Often" [30,] "Not_bul" "Not_bul" [31,] "Both" "Often" [32,] "Both" "Often" [33,] "Both" "Often" [34,] "Boys" "Rarely" [35,] "Not_bul" "Not_bul" [36,] "Not_bul" "Not_bul" [37,] "Boys" "Often" [38,] "Both" "Often" [39,] "Not_bul" "Not_bul" [40,] "Not_bul" "Not_bul" [41,] "Not_bul" "Not_bul" [42,] "Not_bul" "Rarely" [43,] "Girls" "Rarely" [44,] "Not_bul" "Not_bul" [45,] "Not_bul" "Not_bul" [46,] "Not_bul" "Not_bul" [47,] "Boys" "Rarely" [48,] "Not_bul" "Not_bul" [49,] "Girls" "Often" [50,] "Both" "Often" [51,] "Boys" "Rarely" [52,] "Not_bul" "Not_bul" [53,] "Not_bul" "Not_bul" [54,] "Boys" "Rarely" [55,] "Not_bul" "Not_bul" [56,] "Not_bul" "Not_bul" [57,] "Not_bul" "Not_bul" [58,] "Girls" "Rarely" [59,] "Not_bul" "Not_bul" [60,] "Boys" "Often" [61,] "Girls" "Often" [62,] "Girls" "Rarely" [63,] "Boys" "Often" [64,] "Boys" "Rarely" [65,] "Girls" "Rarely" [66,] "Boys" "Rarely" [67,] "Girls" "Rarely" [68,] "Boys" "Often" [69,] "Not_bul" "Not_bul" [70,] "Boys" "Often" [71,] "Girls" "Rarely" [72,] "Not_bul" "Not_bul" [73,] "Not_bul" "Not_bul" [74,] "Not_bul" "Not_bul" [75,] "Both" "Rarely" [76,] "Both" "Rarely" [77,] "Not_bul" "Not_bul" [78,] "Boys" "Rarely" [79,] "Not_bul" "Rarely" [80,] "Not_bul" "Rarely" [81,] "Boys" "Often" [82,] "Not_bul" "Not_bul" [83,] "Both" "Rarely" [84,] "Both" "Not_bul" [85,] "Both" "Often" [86,] "Boys" "Often" [87,] "Boys" "Often" [88,] "Not_bul" "Not_bul" [89,] "Boys" "Often" [90,] "Boys" "Rarely" [91,] "Girls" "Often" [92,] "Girls" "Often" [93,] "Not_bul" "Not_bul" [94,] "Not_bul" "Not_bul" [95,] "Not_bul" "Not_bul" [96,] "Not_bul" "Not_bul" [97,] "Not_bul" "Not_bul" [98,] "Both" "Often" [99,] "Girls" "Often" [100,] "Girls" "Often" [101,] "Not_bul" "Not_bul" [102,] "Not_bul" "Not_bul" [103,] "Not_bul" "Not_bul" [104,] "Girls" "Rarely" [105,] "Boys" "Often" [106,] "Boys" "Rarely" [107,] "Not_bul" "Not_bul" [108,] "Not_bul" "Not_bul" [109,] "Boys" "Often" [110,] "Girls" "Often" [111,] "Boys" "Rarely" [112,] "Not_bul" "Often" [113,] "Not_bul" "Not_bul" [114,] "Boys" "Often" [115,] "Boys" "Often" [116,] "Boys" "Rarely" [117,] "Boys" "Not_bul" [118,] "Not_bul" "Not_bul" [119,] "Boys" "Often" [120,] "Boys" "Rarely" [121,] "Boys" "Often" [122,] "Not_bul" "Not_bul" [123,] "Not_bul" "Not_bul" [124,] "Girls" "Rarely" [125,] "Girls" "Often" [126,] "Not_bul" "Not_bul" [127,] "Boys" "Rarely" [128,] "Boys" "Rarely" [129,] "Not_bul" "Not_bul" [130,] "Boys" "Rarely" [131,] "Boys" "Rarely" [132,] "Boys" "Rarely" [133,] "Not_bul" "Not_bul" [134,] "Not_bul" "Not_bul" [135,] "Not_bul" "Not_bul" [136,] "Girls" "Often" [137,] "Boys" "Rarely" [138,] "Boys" "Rarely" [139,] "Both" "Often" [140,] "Not_bul" "Not_bul" [141,] "Not_bul" "Not_bul" [142,] "Boys" "Often" [143,] "Boys" "Rarely" [144,] "Boys" "Rarely" [145,] "Girls" "Often" [146,] "Not_bul" "Not_bul" [147,] "Not_bul" "Not_bul" [148,] "Girls" "Rarely" [149,] "Not_bul" "Not_bul" [150,] "Boys" "Often" [151,] "Boys" "Often" [152,] "Not_bul" "Not_bul" [153,] "Not_bul" "Not_bul" [154,] "Not_bul" "Not_bul" [155,] "Not_bul" "Not_bul" [156,] "Not_bul" "Not_bul" [157,] "Not_bul" "Not_bul" [158,] "Boys" "Rarely" [159,] "Boys" "Often" [160,] "Not_bul" "Not_bul" [161,] "Boys" "Rarely" [162,] "Not_bul" "Not_bul" [163,] "Boys" "Often" [164,] "Boys" "Rarely" [165,] "Boys" "Rarely" [166,] "Not_bul" "Not_bul" [167,] "Boys" "Often" [168,] "Boys" "Often" [169,] "Not_bul" "Not_bul" [170,] "Not_bul" "Not_bul" [171,] "Not_bul" "Not_bul" [172,] "Not_bul" "Not_bul" [173,] "Not_bul" "Not_bul" [174,] "Both" "Often" [175,] "Boys" "Rarely" [176,] "Both" "Often" [177,] "Boys" "Rarely" [178,] "Both" "Often" [179,] "Boys" "Rarely" [180,] "Both" "Rarely" [181,] "Not_bul" "Not_bul" [182,] "Not_bul" "Not_bul" [183,] "Boys" "Rarely" [184,] "Boys" "Rarely" [185,] "Not_bul" "Not_bul" [186,] "Not_bul" "Not_bul" [187,] "Not_bul" "Not_bul" [188,] "Boys" "Rarely" [189,] "Not_bul" "Not_bul" [190,] "Both" "Often" [191,] "Not_bul" "Not_bul" [192,] "Not_bul" "Not_bul" [193,] "Not_bul" "Not_bul" > (table1 <- table(z[,cat1],z[,cat2])) Not_bul Often Rarely Both 1 13 4 Boys 6 27 37 Girls 0 11 10 Not_bul 80 1 3 > (V1<-dimnames(y)[[1]][cat1]) [1] "gender_of_bully" > (V2<-dimnames(y)[[1]][cat2]) [1] "how_often_bullied" > > #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/1bamz1386246261.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 162.6923, df = 6, p-value < 2.2e-16 Warning message: In chisq.test(table1, simulate.p.value = simulate.p.value) : Chi-squared approximation may be incorrect > 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/25pb41386246262.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/wessaorg/rcomp/tmp/3uigu1386246262.tab") > > > > proc.time() user system elapsed 0.785 0.338 1.087