Kindly refer to description to understand the original data frame.
Let’s explore the data a bit.
data("ToothGrowth")
Supplement <- factor(ToothGrowth$supp)
library(ggplot2)
g <- ggplot(ToothGrowth, aes(ToothGrowth$dose, ToothGrowth$len))
g <- g + geom_point(aes(colour = Supplement)) + labs(
        title = "Tooth Length versus Dose", x = "Dose", y = "Length")
g

s <- split(ToothGrowth, ToothGrowth$supp)
summary(s$OJ$len); summary(s$VC$len)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    8.20   15.52   22.70   20.66   25.72   30.90
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    4.20   11.20   16.50   16.96   23.10   33.90
Are the supplements equally effective?
Let’s do an alpha = .05 one-tailed test on the samples.
t.test(s$OJ$len, s$VC$len, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  s$OJ$len and s$VC$len
## t = 1.9153, df = 55.309, p-value = 0.03032
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.4682687       Inf
## sample estimates:
## mean of x mean of y 
##  20.66333  16.96333
H0 is rejected and the true difference in means is greater than 0.
t.test(s$OJ$len[s$OJ$dose == 0.5], s$VC$len[s$OJ$dose == 0.5], 
       alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  s$OJ$len[s$OJ$dose == 0.5] and s$VC$len[s$OJ$dose == 0.5]
## t = 3.1697, df = 14.969, p-value = 0.003179
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  2.34604     Inf
## sample estimates:
## mean of x mean of y 
##     13.23      7.98
H0 is rejected and the true difference in means is greater than 0 when dose is 0.5 mg/day.
t.test(s$OJ$len[s$OJ$dose == 1], s$VC$len[s$OJ$dose == 1], 
       alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  s$OJ$len[s$OJ$dose == 1] and s$VC$len[s$OJ$dose == 1]
## t = 4.0328, df = 15.358, p-value = 0.0005192
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  3.356158      Inf
## sample estimates:
## mean of x mean of y 
##     22.70     16.77
H0 is rejected and the true difference in means is greater than 0 when dose is 1.0 mg/day.
t.test(s$OJ$len[s$OJ$dose == 2], s$VC$len[s$OJ$dose == 2], 
       alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  s$OJ$len[s$OJ$dose == 2] and s$VC$len[s$OJ$dose == 2]
## t = -0.046136, df = 14.04, p-value = 0.5181
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  -3.1335     Inf
## sample estimates:
## mean of x mean of y 
##     26.06     26.14
Failed to rejected H0 when dose is 2.0 mg/day.
Conclusion: Perhaps orange juice was more effective on tooth growth in guinea pigs than vitamin C for lower doses (i.e. =< 1.0 mg/day). As the doses increased to 2.0 mg/day, no significant difference between the two was noted.
*** Disclaimer: The suggestions and remarks in this page are based on personal research experience. Research practices and approaches vary. Exercise your own judgment regarding the suitability of the content.
*** Analysis environment
sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 14393)
## 
## locale:
## [1] LC_COLLATE=English_Singapore.1252  LC_CTYPE=English_Singapore.1252   
## [3] LC_MONETARY=English_Singapore.1252 LC_NUMERIC=C                      
## [5] LC_TIME=English_Singapore.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_2.2.1
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.8      assertthat_0.1   digest_0.6.10    rprojroot_1.2   
##  [5] plyr_1.8.4       grid_3.3.2       gtable_0.2.0     backports_1.0.5 
##  [9] magrittr_1.5     evaluate_0.10    scales_0.4.1     stringi_1.1.2   
## [13] lazyeval_0.2.0   rmarkdown_1.3    labeling_0.3     tools_3.3.2     
## [17] stringr_1.1.0    munsell_0.4.3    yaml_2.1.14      colorspace_1.3-2
## [21] htmltools_0.3.5  knitr_1.15.1     tibble_1.2