################# 
## Example 27

y = c(101,100,102,104,101,101,99,95,97,94,92,90)
a<-rep(c("A","B","C","D"),each=3)
a
aggregate(y~a,FUN=mean)
aggregate(y~a,FUN=sum)
mean(y)
sum(y)
boxplot(y~a)
plot(rep(1:4,each=3),y) ## point plots
M<-aov(y~a)
anova(M)
summary(M)
TukeyHSD(M)

model.tables(M)

### f Table
alpha=0.05
qf(1-alpha,3,8)

################# 
## Example 28
y = c(101,100,104,101,101,99,95,94,92,90)
a<-rep(c("A","B","C","D"),c(2,3,2,3))
a
aggregate(y~a,FUN=mean)
aggregate(y~a,FUN=sum)
mean(y)
sum(y)
boxplot(y~a)
plot(rep(1:4,c(2,3,2,3)),y) ## point plots

M<-aov(y~a)
anova(M)


### f Table
alpha=0.05
qf(1-alpha,3,6)
#######example 29
x <- c(212, 213, 229,166,124,107,110,81,184,125)
res <- chisq.test(x)
res
qchisq(0.95,9)
#######example 30
x <- c(9,11,17,24)
res <- chisq.test(x)
res
qchisq(0.95,3)




