data(ToothGrowth)
pairs(ToothGrowth)
library(ggplot2)
plt<-ggplot(ToothGrowth, aes(as.factor(supp),len,color=as.factor(supp)))+geom_boxplot()
print(plt)
plt<-ggplot(ToothGrowth, aes(as.factor(dose),len,color=as.factor(dose)))+geom_boxplot()+facet_wrap(~supp)
print(plt)
t.test(len~supp, ToothGrowth[ToothGrowth$dose==.5,])
##
## Welch Two Sample t-test
##
## data: len by supp
## t = 3.1697, df = 14.969, p-value = 0.006359
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.719057 8.780943
## sample estimates:
## mean in group OJ mean in group VC
## 13.23 7.98
t.test(len~supp, ToothGrowth[ToothGrowth$dose==1,])
##
## Welch Two Sample t-test
##
## data: len by supp
## t = 4.0328, df = 15.358, p-value = 0.001038
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 2.802148 9.057852
## sample estimates:
## mean in group OJ mean in group VC
## 22.70 16.77
t.test(len~supp, ToothGrowth[ToothGrowth$dose==2,])
##
## Welch Two Sample t-test
##
## data: len by supp
## t = -0.0461, df = 14.04, p-value = 0.9639
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.79807 3.63807
## sample estimates:
## mean in group OJ mean in group VC
## 26.06 26.14
OJ is better with dose .5 and 1.5 mg.
There is no significant difference between supplements when dose is 2mg.