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('Same' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Same' + ,'Same' + ,'Differnt' + ,'Same' + ,'Not_bul' + ,'Both' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Both' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Differnt' + ,'Differnt' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Differnt' + ,'Differnt' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Differnt' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Same' + ,'Both' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Not_bul' + ,'Both' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Differnt' + ,'Same' + ,'Both' + ,'Differnt' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Both' + ,'Both' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Both' + ,'Same' + ,'Same' + ,'Both' + ,'Differnt' + ,'Not_bul' + ,'Both' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Both' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Same' + ,'Both' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Not_bul' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Same' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Not_bul' + ,'Same' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Both' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Same' + ,'Both' + ,'Differnt' + ,'Not_bul' + ,'Not_bul' + ,'Not_bul' + ,'Same' + ,'Not_bul') + ,dim=c(2 + ,105) + ,dimnames=list(c('girls' + ,'boys') + ,1:105)) > y <- array(NA,dim=c(2,105),dimnames=list(c('girls','boys'),1:105)) > 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' > par3 <- 'Pearson Chi-Square' > par2 <- '2' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: aston2 > #To cite this work: Ian E. Holliday, 2012, STARS Bullying Study (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/Ian.Holliday/rwasp_STARS_Bullying_Study_alt.wasp/ > #Source of accompanying publication: > # > 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,] "Same" "Not_bul" [2,] "Same" "Differnt" [3,] "Same" "Same" [4,] "Differnt" "Same" [5,] "Not_bul" "Both" [6,] "Not_bul" "Differnt" [7,] "Not_bul" "Differnt" [8,] "Same" "Both" [9,] "Not_bul" "Differnt" [10,] "Not_bul" "Differnt" [11,] "Not_bul" "Not_bul" [12,] "Same" "Differnt" [13,] "Differnt" "Not_bul" [14,] "Not_bul" "Not_bul" [15,] "Differnt" "Differnt" [16,] "Differnt" "Same" [17,] "Not_bul" "Same" [18,] "Differnt" "Differnt" [19,] "Not_bul" "Not_bul" [20,] "Not_bul" "Differnt" [21,] "Same" "Not_bul" [22,] "Not_bul" "Not_bul" [23,] "Not_bul" "Not_bul" [24,] "Not_bul" "Differnt" [25,] "Differnt" "Differnt" [26,] "Differnt" "Not_bul" [27,] "Not_bul" "Not_bul" [28,] "Both" "Not_bul" [29,] "Not_bul" "Differnt" [30,] "Same" "Differnt" [31,] "Not_bul" "Same" [32,] "Same" "Same" [33,] "Both" "Not_bul" [34,] "Same" "Same" [35,] "Not_bul" "Not_bul" [36,] "Same" "Not_bul" [37,] "Same" "Same" [38,] "Not_bul" "Not_bul" [39,] "Both" "Not_bul" [40,] "Both" "Same" [41,] "Not_bul" "Same" [42,] "Not_bul" "Differnt" [43,] "Same" "Differnt" [44,] "Same" "Both" [45,] "Differnt" "Not_bul" [46,] "Same" "Not_bul" [47,] "Same" "Not_bul" [48,] "Same" "Both" [49,] "Not_bul" "Not_bul" [50,] "Not_bul" "Differnt" [51,] "Not_bul" "Not_bul" [52,] "Not_bul" "Both" [53,] "Both" "Both" [54,] "Same" "Same" [55,] "Not_bul" "Differnt" [56,] "Not_bul" "Both" [57,] "Same" "Same" [58,] "Both" "Differnt" [59,] "Not_bul" "Both" [60,] "Same" "Not_bul" [61,] "Same" "Same" [62,] "Not_bul" "Differnt" [63,] "Not_bul" "Not_bul" [64,] "Both" "Both" [65,] "Not_bul" "Not_bul" [66,] "Not_bul" "Not_bul" [67,] "Same" "Same" [68,] "Same" "Not_bul" [69,] "Not_bul" "Same" [70,] "Same" "Both" [71,] "Not_bul" "Same" [72,] "Differnt" "Same" [73,] "Both" "Same" [74,] "Not_bul" "Same" [75,] "Not_bul" "Differnt" [76,] "Same" "Not_bul" [77,] "Both" "Not_bul" [78,] "Not_bul" "Not_bul" [79,] "Differnt" "Same" [80,] "Same" "Not_bul" [81,] "Same" "Differnt" [82,] "Not_bul" "Not_bul" [83,] "Same" "Not_bul" [84,] "Same" "Differnt" [85,] "Not_bul" "Not_bul" [86,] "Not_bul" "Differnt" [87,] "Not_bul" "Not_bul" [88,] "Not_bul" "Not_bul" [89,] "Not_bul" "Not_bul" [90,] "Not_bul" "Not_bul" [91,] "Both" "Not_bul" [92,] "Not_bul" "Not_bul" [93,] "Same" "Same" [94,] "Both" "Differnt" [95,] "Not_bul" "Not_bul" [96,] "Not_bul" "Same" [97,] "Not_bul" "Same" [98,] "Not_bul" "Same" [99,] "Differnt" "Same" [100,] "Same" "Differnt" [101,] "Same" "Not_bul" [102,] "Both" "Not_bul" [103,] "Differnt" "Not_bul" [104,] "Differnt" "Same" [105,] "Both" "Not_bul" > (table1 <- table(z[,cat1],z[,cat2])) Both Differnt Not_bul Same Both 2 2 7 2 Differnt 0 3 4 6 Not_bul 4 13 22 9 Same 4 7 11 9 > (V1<-dimnames(y)[[1]][cat1]) [1] "girls" > (V2<-dimnames(y)[[1]][cat2]) [1] "boys" > > #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/1pf4q1386281848.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 7.8782, df = 9, p-value = 0.5465 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/fisher/rcomp/tmp/2nq0f1386281848.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/3ye971386281848.tab") > > > > proc.time() user system elapsed 0.860 0.331 1.122