#q1
power.anova.test(groups = 4, n = NULL,
                 between.var = var(c(18,19,19,20)),
                 within.var  = 3.5,
                 sig.level   = 0.05,
                 power       = 0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 20.08368
##     between.var = 0.6666667
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group
power.anova.test(groups = 4, n = NULL,
                 between.var = var(c(18, 18.66, 19.33, 20)),
                 within.var  = 3.5,
                 sig.level   = 0.05,
                 power       = 0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 18.16131
##     between.var = 0.7414917
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group
power.anova.test(groups = 4, n = NULL,
                 between.var = var(c(18, 18, 20, 20)),
                 within.var  = 3.5,
                 sig.level   = 0.05,
                 power       = 0.80)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##          groups = 4
##               n = 10.56952
##     between.var = 1.333333
##      within.var = 3.5
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group
#q2
fluid_type <- c(1,1,1,1,1,1,
                2,2,2,2,2,2,
                3,3,3,3,3,3,
                4,4,4,4,4,4)
life <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6, 
          16.9, 15.3, 18.6, 17.1, 19.5, 20.3,
          21.4, 23.6, 19.4, 18.5, 20.5, 22.3, 
          19.3, 21.1, 16.9, 17.5, 18.3, 19.8)

dat1 <- data.frame(fluid_type, life)

dat1$fluid_type <- as.factor(dat1$fluid_type)
#fluid_type <as.factor(fluid_type)
str(dat1$fluid_type)
##  Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 2 2 2 2 ...
aov.model<-aov(dat1$life~dat1$fluid_type,data=dat1)
summary(aov.model)
##                 Df Sum Sq Mean Sq F value Pr(>F)  
## dat1$fluid_type  3  30.16   10.05   3.047 0.0525 .
## Residuals       20  65.99    3.30                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov.model)

tukey_model<- TukeyHSD(aov.model, conf.level = 0.9)
plot(tukey_model)