R, anova

> head(PlantGrowth) 
weight group 
1 4.17 ctrl 
2 5.58 ctrl 
3 5.18 ctrl 
4 6.11 ctrl 
5 4.50 ctrl 
6 4.61 ctrl

> levels(PlantGrowth$group) 
[1] "ctrl" "trt1" "trt2"

> m = aov(weight ~ group, data = PlantGrowth) 
> summary(m)  
          Df Sum Sq Mean Sq F value Pr(>F) 
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

> install.packages("DescTools")
> library(DescTools) 
> PostHocTest(m, method='bonferroni') 

Posthoc multiple comparisons of means : Bonferroni 
95% family-wise confidence level 

$group 
            diff     lwr.ci    upr.ci   pval 
trt1-ctrl -0.371 -1.0825786 0.3405786 0.5832 
trt2-ctrl  0.494 -0.2175786 1.2055786 0.2630 
trt2-trt1  0.865  0.1534214 1.5765786 0.0134 * 
--- 
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

PostHocTest(m, method='lsd') # Fisher's LSD
PostHocTest(m, method='hsd') # Tuckey's HSD
PostHocTest(m, method='scheffe') # Scheffe's method