############################################################################ ### load data data(ToothGrowth) ### turn dose into a factor ToothGrowth$dose <- factor(ToothGrowth$dose) ### boxplot boxplot(len ~ dose*supp, data=ToothGrowth, col="lightgray", xlab="Condition", ylab="Length of Odontoblasts", boxwex=0.5) ### two-way ANOVA res <- aov(len ~ dose*supp, data=ToothGrowth) summary(res) ### pairwise comparisons TukeyHSD(res) ############################################################################ ### load data data(iris) ### correlation matrix round(cor(iris[,1:4]), 2) ### scatterplot matrix color <- c(rep("red", 50), rep("green", 50), rep("blue", 50)) pairs(iris[,1:4], pch=19, col=color, cex=.8) ############################################################################ ### load data data(Puromycin) ### plot data plot(Puromycin$conc, Puromycin$rate, pch=19, ylim=c(50,220), col = ifelse(Puromycin$state == "treated", "red", "blue"), xlab = "Substrate Concentration (ppm)", ylab = "Reaction Velocity (counts/min/min)") ### add legend legend("bottomright", inset=.02, pch=19, col=c("red","blue"), legend=c("treated","untreated")) ### fit regression model res <- lm(rate ~ I(log(conc))*state, data=Puromycin) ### add fitted lines to plot newdat <- data.frame(state="untreated", conc=seq(0, 1.5, .01)) lines(newdat$conc, predict(res, newdat), lwd=2, col="blue") newdat <- data.frame(state="treated", conc=seq(0, 1.5, .01)) lines(newdat$conc, predict(res, newdat), lwd=2, col="red") ############################################################################