# http://stat.ethz.ch/R-manual/R-patched/library/stats/html/fisher.test.html # Creating matrix: academic degree vs. ratings > ratings1_AcadDegree <- matrix(c(1,12,5,21,6,0, 0,2,0,2,1,0, 1,10,6,10,3,0, 0,1,0,0,0,0), nrow = 4, ncol = 6, byrow = TRUE, dimnames = list(c("1st more cohesive", "2nd more cohesive", "Equally coh", "Don't know"), c("Undergrad", "Grad", "Grad Cert Expert", "Master", "PhD", "No degree"))) > ratings1_AcadDegree Undergrad Grad Grad Cert Expert Master PhD No degree 1st more cohesive 1 12 5 21 6 0 2nd more cohesive 0 2 0 2 1 0 Equally coh 1 10 6 10 3 0 Don't know 0 1 0 0 0 0 > ratings2_AcadDegree <- matrix(c(2,17,9,22,5,0, 0,3,2,1,4,0, 0,4,0,10,0,0, 0,1,0,0,0,0), nrow = 4, ncol = 6, byrow = TRUE, dimnames = list(c("1st more cohesive", "2nd more cohesive", "Equally coh", "Don't know"), c("Undergrad", "Grad", "Grad Cert Expert", "Master", "PhD", "No degree"))) > ratings2_AcadDegree Undergrad Grad Grad Cert Expert Master PhD No degree 1st more cohesive 2 17 9 22 5 0 2nd more cohesive 0 3 2 1 4 0 Equally coh 0 4 0 10 0 0 Don't know 0 1 0 0 0 0 > ratings3_AcadDegree <- matrix(c(0,1,1,3,1,0, 1,15,5,17,5,0, 1,9,4,13,3,0, 0,0,1,0,0,0), nrow = 4, ncol = 6, byrow = TRUE, dimnames = list(c("1st more cohesive", "2nd more cohesive", "Equally coh", "Don't know"), c("Undergrad", "Grad", "Grad Cert Expert", "Master", "PhD", "No degree"))) > ratings3_AcadDegree Undergrad Grad Grad \nCert Expert Master PhD No degree 1st more cohesive 0 1 1 3 1 0 2nd more cohesive 1 15 5 17 5 0 Equally coh 1 9 4 13 3 0 Don't know 0 0 1 0 0 0 # Executing the Fisher exact test between Academic degree and Ratings > fisher.test(ratings1_AcadDegree, simulate.p.value = TRUE) Fisher's Exact Test for Count Data with simulated p-value (based on 2000 replicates) data: ratings1_AcadDegree p-value = 0.8656 alternative hypothesis: two.sided > fisher.test(ratings1_AcadDegree) Fisher's Exact Test for Count Data data: ratings1_AcadDegree p-value = 0.8646 alternative hypothesis: two.sided > fisher.test(ratings2_AcadDegree, simulate.p.value = TRUE) Fisher's Exact Test for Count Data with simulated p-value (based on 2000 replicates) data: ratings2_AcadDegree p-value = 0.04098 alternative hypothesis: two.sided > fisher.test(ratings2_AcadDegree) Fisher's Exact Test for Count Data data: ratings2_AcadDegree p-value = 0.03684 alternative hypothesis: two.sided > fisher.test(ratings3_AcadDegree, simulate.p.value = TRUE) Fisher's Exact Test for Count Data with simulated p-value (based on 2000 replicates) data: ratings3_AcadDegree p-value = 0.8716 alternative hypothesis: two.sided > fisher.test(ratings3_AcadDegree) Fisher's Exact Test for Count Data data: ratings3_AcadDegree p-value = 0.8831 alternative hypothesis: two.sided