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('Often' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Rarely' + ,'Same' + ,'Often' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Not_bul' + ,'Rarely' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Not_bul' + ,'Same' + ,'Often' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Not_bul' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Often' + ,'Both' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Rarely' + ,'Same' + ,'Often' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Both' + ,'Often' + ,'Both' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Both' + ,'Rarely' + ,'Both' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Often' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Often' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Differnt' + ,'Often' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Often' + ,'Not_bul' + ,'Rarely' + ,'Same' + ,'Often' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Rarely' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Often' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul') + ,dim=c(2 + ,193) + ,dimnames=list(c('how_often_bullied' + ,'which_year') + ,1:193)) > y <- array(NA,dim=c(2,193),dimnames=list(c('how_often_bullied','which_year'),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,] "Often" "Same" [2,] "Not_bul" "Same" [3,] "Rarely" "Same" [4,] "Rarely" "Differnt" [5,] "Not_bul" "Not_bul" [6,] "Not_bul" "Differnt" [7,] "Not_bul" "Same" [8,] "Not_bul" "Not_bul" [9,] "Not_bul" "Not_bul" [10,] "Rarely" "Same" [11,] "Not_bul" "Not_bul" [12,] "Often" "Both" [13,] "Often" "Same" [14,] "Often" "Differnt" [15,] "Not_bul" "Not_bul" [16,] "Not_bul" "Not_bul" [17,] "Rarely" "Differnt" [18,] "Rarely" "Both" [19,] "Not_bul" "Differnt" [20,] "Not_bul" "Not_bul" [21,] "Rarely" "Differnt" [22,] "Not_bul" "Not_bul" [23,] "Not_bul" "Same" [24,] "Often" "Differnt" [25,] "Often" "Differnt" [26,] "Not_bul" "Not_bul" [27,] "Not_bul" "Not_bul" [28,] "Rarely" "Differnt" [29,] "Often" "Same" [30,] "Not_bul" "Not_bul" [31,] "Often" "Same" [32,] "Often" "Differnt" [33,] "Often" "Differnt" [34,] "Rarely" "Differnt" [35,] "Not_bul" "Not_bul" [36,] "Not_bul" "Not_bul" [37,] "Often" "Differnt" [38,] "Often" "Differnt" [39,] "Not_bul" "Not_bul" [40,] "Not_bul" "Not_bul" [41,] "Not_bul" "Not_bul" [42,] "Rarely" "Not_bul" [43,] "Rarely" "Same" [44,] "Not_bul" "Not_bul" [45,] "Not_bul" "Not_bul" [46,] "Not_bul" "Not_bul" [47,] "Rarely" "Differnt" [48,] "Not_bul" "Not_bul" [49,] "Often" "Differnt" [50,] "Often" "Differnt" [51,] "Rarely" "Differnt" [52,] "Not_bul" "Not_bul" [53,] "Not_bul" "Not_bul" [54,] "Rarely" "Both" [55,] "Not_bul" "Not_bul" [56,] "Not_bul" "Not_bul" [57,] "Not_bul" "Not_bul" [58,] "Rarely" "Same" [59,] "Not_bul" "Not_bul" [60,] "Often" "Same" [61,] "Often" "Both" [62,] "Rarely" "Same" [63,] "Often" "Differnt" [64,] "Rarely" "Differnt" [65,] "Rarely" "Not_bul" [66,] "Rarely" "Same" [67,] "Rarely" "Same" [68,] "Often" "Same" [69,] "Not_bul" "Not_bul" [70,] "Often" "Same" [71,] "Rarely" "Same" [72,] "Not_bul" "Not_bul" [73,] "Not_bul" "Not_bul" [74,] "Not_bul" "Not_bul" [75,] "Rarely" "Both" [76,] "Rarely" "Both" [77,] "Not_bul" "Not_bul" [78,] "Rarely" "Same" [79,] "Rarely" "Not_bul" [80,] "Rarely" "Not_bul" [81,] "Often" "Same" [82,] "Not_bul" "Not_bul" [83,] "Rarely" "Same" [84,] "Not_bul" "Same" [85,] "Often" "Differnt" [86,] "Often" "Same" [87,] "Often" "Differnt" [88,] "Not_bul" "Same" [89,] "Often" "Differnt" [90,] "Rarely" "Both" [91,] "Often" "Same" [92,] "Often" "Same" [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,] "Often" "Not_bul" [99,] "Often" "Both" [100,] "Often" "Same" [101,] "Not_bul" "Not_bul" [102,] "Not_bul" "Not_bul" [103,] "Not_bul" "Not_bul" [104,] "Rarely" "Same" [105,] "Often" "Both" [106,] "Rarely" "Both" [107,] "Not_bul" "Not_bul" [108,] "Not_bul" "Not_bul" [109,] "Often" "Differnt" [110,] "Often" "Same" [111,] "Rarely" "Same" [112,] "Often" "Not_bul" [113,] "Not_bul" "Not_bul" [114,] "Often" "Both" [115,] "Often" "Both" [116,] "Rarely" "Same" [117,] "Not_bul" "Differnt" [118,] "Not_bul" "Not_bul" [119,] "Often" "Both" [120,] "Rarely" "Both" [121,] "Often" "Same" [122,] "Not_bul" "Not_bul" [123,] "Not_bul" "Not_bul" [124,] "Rarely" "Same" [125,] "Often" "Same" [126,] "Not_bul" "Not_bul" [127,] "Rarely" "Differnt" [128,] "Rarely" "Same" [129,] "Not_bul" "Not_bul" [130,] "Rarely" "Both" [131,] "Rarely" "Differnt" [132,] "Rarely" "Both" [133,] "Not_bul" "Not_bul" [134,] "Not_bul" "Not_bul" [135,] "Not_bul" "Not_bul" [136,] "Often" "Same" [137,] "Rarely" "Same" [138,] "Rarely" "Differnt" [139,] "Often" "Both" [140,] "Not_bul" "Not_bul" [141,] "Not_bul" "Not_bul" [142,] "Often" "Differnt" [143,] "Rarely" "Both" [144,] "Rarely" "Same" [145,] "Often" "Same" [146,] "Not_bul" "Not_bul" [147,] "Not_bul" "Not_bul" [148,] "Rarely" "Same" [149,] "Not_bul" "Not_bul" [150,] "Often" "Same" [151,] "Often" "Same" [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,] "Rarely" "Same" [159,] "Often" "Both" [160,] "Not_bul" "Not_bul" [161,] "Rarely" "Same" [162,] "Not_bul" "Not_bul" [163,] "Often" "Same" [164,] "Rarely" "Same" [165,] "Rarely" "Same" [166,] "Not_bul" "Not_bul" [167,] "Often" "Differnt" [168,] "Often" "Both" [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,] "Often" "Not_bul" [175,] "Rarely" "Same" [176,] "Often" "Not_bul" [177,] "Rarely" "Same" [178,] "Often" "Same" [179,] "Rarely" "Differnt" [180,] "Rarely" "Both" [181,] "Not_bul" "Not_bul" [182,] "Not_bul" "Not_bul" [183,] "Rarely" "Differnt" [184,] "Rarely" "Differnt" [185,] "Not_bul" "Not_bul" [186,] "Not_bul" "Not_bul" [187,] "Not_bul" "Not_bul" [188,] "Rarely" "Differnt" [189,] "Not_bul" "Not_bul" [190,] "Often" "Same" [191,] "Not_bul" "Not_bul" [192,] "Not_bul" "Not_bul" [193,] "Not_bul" "Not_bul" > (table1 <- table(z[,cat1],z[,cat2])) Both Differnt Not_bul Same Not_bul 0 3 79 5 Often 10 16 4 22 Rarely 11 15 4 24 > (V1<-dimnames(y)[[1]][cat1]) [1] "how_often_bullied" > (V2<-dimnames(y)[[1]][cat2]) [1] "which_year" > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/1d6hc1354479657.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 134.6066, df = 6, p-value < 2.2e-16 > 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/fisher/rcomp/tmp/20tdr1354479657.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/fisher/rcomp/tmp/3pyv41354479657.tab") > > > > proc.time() user system elapsed 0.428 0.132 0.540