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' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Both' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Differnt' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Differnt' + ,'Often' + ,'Both' + ,'Often' + ,'Same' + ,'Often' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Same' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Both' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt' + ,'Rarely' + ,'Differnt') + ,dim=c(2 + ,98) + ,dimnames=list(c('how_often' + ,'which_year') + ,1:98)) > y <- array(NA,dim=c(2,98),dimnames=list(c('how_often','which_year'),1:98)) > 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 = '1' > par1 = '2' > 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,] "Often" "Both" [3,] "Often" "Same" [4,] "Often" "Differnt" [5,] "Often" "Differnt" [6,] "Often" "Differnt" [7,] "Often" "Same" [8,] "Often" "Same" [9,] "Often" "Differnt" [10,] "Often" "Differnt" [11,] "Often" "Differnt" [12,] "Often" "Differnt" [13,] "Often" "Differnt" [14,] "Often" "Differnt" [15,] "Often" "Same" [16,] "Often" "Both" [17,] "Often" "Differnt" [18,] "Often" "Same" [19,] "Often" "Same" [20,] "Often" "Same" [21,] "Often" "Differnt" [22,] "Often" "Same" [23,] "Often" "Differnt" [24,] "Often" "Differnt" [25,] "Often" "Same" [26,] "Often" "Same" [27,] "Often" "Both" [28,] "Often" "Same" [29,] "Often" "Both" [30,] "Often" "Differnt" [31,] "Often" "Same" [32,] "Often" "Both" [33,] "Often" "Both" [34,] "Often" "Both" [35,] "Often" "Same" [36,] "Often" "Same" [37,] "Often" "Same" [38,] "Often" "Both" [39,] "Often" "Differnt" [40,] "Often" "Same" [41,] "Often" "Same" [42,] "Often" "Same" [43,] "Often" "Both" [44,] "Often" "Same" [45,] "Often" "Differnt" [46,] "Often" "Both" [47,] "Often" "Same" [48,] "Often" "Same" [49,] "Rarely" "Same" [50,] "Rarely" "Differnt" [51,] "Rarely" "Same" [52,] "Rarely" "Differnt" [53,] "Rarely" "Both" [54,] "Rarely" "Differnt" [55,] "Rarely" "Differnt" [56,] "Rarely" "Differnt" [57,] "Rarely" "Same" [58,] "Rarely" "Differnt" [59,] "Rarely" "Differnt" [60,] "Rarely" "Both" [61,] "Rarely" "Same" [62,] "Rarely" "Same" [63,] "Rarely" "Differnt" [64,] "Rarely" "Same" [65,] "Rarely" "Same" [66,] "Rarely" "Same" [67,] "Rarely" "Both" [68,] "Rarely" "Both" [69,] "Rarely" "Same" [70,] "Rarely" "Same" [71,] "Rarely" "Both" [72,] "Rarely" "Same" [73,] "Rarely" "Both" [74,] "Rarely" "Same" [75,] "Rarely" "Same" [76,] "Rarely" "Both" [77,] "Rarely" "Same" [78,] "Rarely" "Differnt" [79,] "Rarely" "Same" [80,] "Rarely" "Both" [81,] "Rarely" "Differnt" [82,] "Rarely" "Both" [83,] "Rarely" "Same" [84,] "Rarely" "Differnt" [85,] "Rarely" "Both" [86,] "Rarely" "Same" [87,] "Rarely" "Same" [88,] "Rarely" "Same" [89,] "Rarely" "Same" [90,] "Rarely" "Same" [91,] "Rarely" "Same" [92,] "Rarely" "Same" [93,] "Rarely" "Same" [94,] "Rarely" "Differnt" [95,] "Rarely" "Both" [96,] "Rarely" "Differnt" [97,] "Rarely" "Differnt" [98,] "Rarely" "Differnt" > (table1 <- table(z[,cat1],z[,cat2])) Often Rarely Both 10 11 Differnt 16 15 Same 22 24 > (V1<-dimnames(y)[[1]][cat1]) [1] "which_year" > (V2<-dimnames(y)[[1]][cat2]) [1] "how_often" > > #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/1w6bi1354194546.tab") > (cst<-chisq.test(table1, simulate.p.value=simulate.p.value) ) Pearson's Chi-squared test data: table1 X-squared = 0.1261, df = 2, p-value = 0.9389 > 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/2s4i01354194546.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/3z85s1354194547.tab") > > > > proc.time() user system elapsed 0.336 0.088 0.398