I Always fail in remember the code to show how this models are related, so I will put here for my future me. An important thing to do is check the p-values.
The data, according help(sleep):
Data which show the effect of two soporific drugs (increase in hours of sleep compared to control) on 10 patients -Scheffé, Henry (1959) The Analysis of Variance. New York, NY: Wiley.
anova <-aov(extra ~ group, data = sleep)summary(anova)
Df Sum Sq Mean Sq F value Pr(>F)
group 1 12.48 12.482 3.463 0.0792 .
Residuals 18 64.89 3.605
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
tidy(anova)
# A tibble: 2 × 6
term df sumsq meansq statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 group 1 12.5 12.5 3.46 0.0792
2 Residuals 18 64.9 3.60 NA NA
\(t\)-test
Code
t_test <-t.test(extra ~ group, var.equal =TRUE, data = sleep) t_test
Two Sample t-test
data: extra by group
t = -1.8608, df = 18, p-value = 0.07919
alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0
95 percent confidence interval:
-3.363874 0.203874
sample estimates:
mean in group 1 mean in group 2
0.75 2.33