### importing and attaching the dataset [DIET] library(readxl) diet <- read_excel("state-data.xlsx", sheet="diet") # group variable as factor diet$regime <- factor(diet$regime) attach(diet) ### some descriptive statistics mean(coagulation); var(coagulation); sd(coagulation) median(coagulation); quantile(coagulation) summary(coagulation) boxplot(coagulation) # descriptive statistics by groups summary(rbind.data.frame(split(coagulation, regime))) library(ggplot2) ggplot(diet, aes(x=regime, y=coagulation, color = regime)) + geom_boxplot() ### one-way anova ## testing homoskedasticity of variances (Bartlett's and Levene's tests) bartlett.test(coagulation ~ regime) library(car) leveneTest(coagulation ~ regime, center=mean) ## one-way ANOVA anova(lm(coagulation ~ regime)) ## post-hoc tests pairwise.t.test(coagulation, regime, p.adjust.method = "none") pairwise.t.test(coagulation, regime, p.adjust.method = "bonferroni") tukey.posthoc <- TukeyHSD(aov(lm(coagulation~regime))) tukey.posthoc plot(tukey.posthoc)