Anova

library(tidyverse)
library(factoextra)
library(cowplot)
library(ggpubr)
library(cluster)
library(purrr)
library(dplyr)
library(readxl)
View(PlantGrowth)
?PlantGrowth

Variables:

data <- PlantGrowth
table(data$group)
## 
## ctrl trt1 trt2 
##   10   10   10
aggregate(weight~group, data=data, FUN = mean)
##   group weight
## 1  ctrl  5.032
## 2  trt1  4.661
## 3  trt2  5.526
ggplot(data= data, aes(x=group, y=weight, color = group)) + geom_boxplot() + theme_bw()

anova = aov(data$weight ~data$group)
summary(anova)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## data$group   2  3.766  1.8832   4.846 0.0159 *
## Residuals   27 10.492  0.3886                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Aquí el p value es de 0.0159 lo cuál significa que se esta aceptando la hipótesis alternativa de que las medias son diferentes.

plot(TukeyHSD(anova))

Aquí podemos ver que trt2-trt1 no toca nunca la línea, un indicador de que las medias son diferentes.