title: “Basic Inferential Data Analysis” author: “Atreyee” date: “9/20/2026” output: pdf_document
PART 2: TOOTHGROWTH ANALYSIS
library(datasets) data(ToothGrowth)
str(ToothGrowth) head(ToothGrowth)
summary(ToothGrowth)
aggregate(len ~ supp + dose, data = ToothGrowth, FUN = function(x) c(mean = mean(x), sd = sd(x)))
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”)
t_supp <- t.test(len ~ supp, data = ToothGrowth) t_supp
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