options(scipen=999)
options(digits=6)
cat("\014") # clear screen
rm(list=ls(all=TRUE))

row1=c(15,34,40,3,8)
row2=c(13,28,36,19,4)
row3=c(12,35,38,6,9)
obs=rbind(row1,row2,row3)
M <- as.table(obs)
dimnames(M) <- list(Age = c("Type1","Type2","Type3"),
                    Effect = c("A","B","C","D","F"))
Xsq <- chisq.test(M,correct = FALSE)  # Prints test summary
Xsq
Xsq$observed  # observed counts (same as M)
Xsq$expected  # expected counts under the null


row1=c(15,34,40,3,8)
row2=c(13,28,36,19,4)
row3=c(12,35,38,6,9)
obs=rbind(row1,row2,row3)
chisq.test(obs,correct = FALSE)
