#This is how we input the data in Table 1 in Chapter 3 table1ch3=matrix(c(11,23,31,47,10,62,11,3,22,4,11,23,17,1,0,37,9,8,1,51),byrow=TRUE,ncol=5) #This tells R to print out the table so that we can see it print("This is Table 1 in Chapter 3") print(table1ch3) #This tells R to sum up all the values in the table table1ch3sum = sum(table1ch3) #This tells R to print out the sum so that we can see it print("This is the sum of the values in Table 1 of Chapter 3") print(table1ch3sum) #This tells R to perform a chi-square test on Table 1 of Chapter 3 test=chisq.test(table1ch3) #This tells R to print out the results of the chi-square test print(test) #This tells R to calculate the effect size and print it out #The effect size is the square root of the chi-square value divided by the sum of the table multiplied by either the number of columns - 1 or the number of rows - 1, whichever is smaller. In this case the smaller number is the number of rows, which is 4, so the sum of the table is multiplied by 3. cramer=sqrt(test$statistic/(table1ch3sum*3)) print(cramer) print("This is the effect size")