dim(ToothGrowth)
## [1] 60  3
names(ToothGrowth)
## [1] "len"  "supp" "dose"
head(as.data.frame(ToothGrowth))
##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5
## 5  6.4   VC  0.5
## 6 10.0   VC  0.5
aggregate(len ~ supp, mean, data=ToothGrowth)
##   supp      len
## 1   OJ 20.66333
## 2   VC 16.96333
aggregate(len ~ supp, sd, data=ToothGrowth)
##   supp      len
## 1   OJ 6.605561
## 2   VC 8.266029
aggregate(len ~ supp, length, data=ToothGrowth)
##   supp len
## 1   OJ  30
## 2   VC  30
lattice::bwplot(len ~ supp, data=ToothGrowth, 
                main="Distribution of length scores by different supplyment",
                xlab="supplyments", ylab="length")

t.test(len ~ supp, data=ToothGrowth)
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 1.9153, df = 55.309, p-value = 0.06063
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1710156  7.5710156
## sample estimates:
## mean in group OJ mean in group VC 
##         20.66333         16.96333
multicon::diffPlot(len ~ supp, data=ToothGrowth, grp.names=c("OJ", "VC"),
 xlab="supplyments", ylab="length")

with(ToothGrowth, lattice::histogram(~ len | supp, type="density", xlab="Headache score"))

p=.6> 0.05,在95%信心水準之下,保留虛無假設,使用不同維他命的兩組並沒有達到顯著差異。