###task 1
K<-matrix(c(51, 13, 33, 31), nrow=2)
a<-chisq.test(K)
a$expected
a$stdres

###task 2
tea<-data.frame(
  tea=c("0", "0", "g", "g", "b", "b"),
  cancer=c(0,1,0,1,0,1),
  freq= c(130, 55, 357, 65, 160, 45))
a<-chisq.test(xtabs(freq~tea+cancer,
                    data=tea))
tea.tab<-xtabs(freq~tea+cancer,
                    data=tea)
print(a)
a$stdres
library(epitools)
epitab(tea.tab)

epitab(tea.tab[2:3,])

####task 3
cn<-matrix(c (26,	4, 124, 346), byrow=T, ncol = 2)
chisq.test(cn)
library(psych)
phi(cn)

fr<-matrix(c(120,126,30,224), byrow=T, ncol = 2)
chisq.test(fr)
phi(fr)

cs<-matrix(c(0,10,150,340), byrow=T, ncol = 2)
chisq.test(cs)
phi(cs)
