# data from Table 5.4.2 data <- matrix(scan(),ncol=3,byrow=TRUE) 2 2 0 0 1 2 data table542 <- data.frame(data) colnames(table542) <- c("NotSatisfied","SomewhatSatisfied","VerySatisfied") rownames(table542) <- c("Physician","Self") table542 rm(data) # by default the large sample approximation is used, # but a warning message is printed chisq.test(table542) # Here we sample from the permutation distribution chisq.test(table542,simulate.p.value=TRUE,B=5000) rm(table542)