將ToothGrowth資料命名為dta
從頭顯示資料 (由supplement VC起頭)
## 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
從尾顯示資料 (由supplement OJ起頭)
## len supp dose
## 55 24.8 OJ 2
## 56 30.9 OJ 2
## 57 26.4 OJ 2
## 58 27.3 OJ 2
## 59 29.4 OJ 2
## 60 23.0 OJ 2
顯示Supplement OJ和Supplement VC的mean
## supp len
## 1 OJ 20.66333
## 2 VC 16.96333
Length & Supplement的盒狀圖
lattice::bwplot(len ~ supp, data=dta,
main="Distribution of length at different supplements",
xlab="Supplement (OJ & VC)", ylab="Length")不同的supplement是否對於牙齒的生長有差異(t-test)
##
## 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
Q:Investigate if type of vitamin supplement(x) has an effect on teeth growth(y) in guinea pigs.
According to t-test, two kinds of supplements have a different effect on teeth growth.