outcome <- c(1.4, 2.1, 3.0, 2.1, 3.2, 4.7, 3.5, 4.5, 5.4)
treatment1 <- factor(c(1, 1, 1, 2, 2, 2, 3, 3, 3))
# one-way ANOVA
anova1 <- aov(outcome ~ treatment1)
summary(anova1)
etaSquared(anova1)
# include the full ANOVA table
etaSquared(anova1, anova = TRUE)
# two-way ANOVA
treatment2 <- factor(c(1, 2, 3, 1, 2, 3, 1, 2, 3))
anova2 <- aov(outcome ~ treatment1 + treatment2)
etaSquared(anova2)
Run the code above in your browser using DataLab