# Cold2 Example # Test whether the number of colds is independent of the # treatment using a chi-squared test for independence. table = matrix(scan( ), 2, 2, byrow=T) 31 109 17 122 cat("2x2 Contingency Table for Cold1 Example:\n") print(table) # Construct data vectors placebo = c(rep(1, table[1,1]), rep(0, table[1,2])) ascorb = c(rep(1, table[2,1]), rep(0, table[2,2])) cat("Print data vectors:\n") cat("Placebo:\n") print(placebo) cat("Ascorbic Acid:\n") print(ascorb) # Perform independent 2-sample t-test. t.test(placebo, ascorb)