title: “Basic Inferential Data Analysis” author: “Atreyee” date: “9/20/2026” output: pdf_document

PART 2: TOOTHGROWTH ANALYSIS

—- Load and Explore Data —-

library(datasets) data(ToothGrowth)

str(ToothGrowth) head(ToothGrowth)

—- Basic Summary —-

summary(ToothGrowth)

Summary table by group

aggregate(len ~ supp + dose, data = ToothGrowth, FUN = function(x) c(mean = mean(x), sd = sd(x)))

—- Exploratory Plots —-

boxplot(len ~ supp, data = ToothGrowth, col = c(“orange”, “lightblue”), main = “Tooth Length by Supplement Type”, xlab = “Supplement”, ylab = “Tooth Length”)

boxplot(len ~ dose, data = ToothGrowth, col = “lightgreen”, main = “Tooth Length by Dose”, xlab = “Dose (mg)”, ylab = “Tooth Length”)

boxplot(len ~ supp * dose, data = ToothGrowth, col = rainbow(6), main = “Tooth Length by Supplement and Dose”, xlab = “Supplement.Dose”, ylab = “Tooth Length”)

—- Hypothesis Tests: Compare by Supplement —-

t_supp <- t.test(len ~ supp, data = ToothGrowth) t_supp

—- Hypothesis Tests: Compare by Dose (pairwise) —-

t_dose_05_1 <- t.test(len ~ dose, data = subset(ToothGrowth, dose %in% c(0.5, 1))) t_dose_1_2 <- t.test(len ~ dose, data = subset(ToothGrowth, dose %in% c(1, 2))) t_dose_05_2 <- t.test(len ~ dose, data = subset(ToothGrowth, dose %in% c(0.5, 2)))

t_dose_05_1 t_dose_1_2 t_dose_05_2