library(knitr)
library(ggplot2)
opts_chunk$set(echo=TRUE, results='markup')
data(ToothGrowth)
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
str(ToothGrowth)
## 'data.frame': 60 obs. of 3 variables:
## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
## $ dose: Factor w/ 3 levels "0.5","1","2": 1 1 1 1 1 1 1 1 1 1 ...
The number of variables is 3:
and are 60 observation on the set.
summary(ToothGrowth)
## len supp dose
## Min. : 4.2 OJ:30 0.5:20
## 1st Qu.:13.1 VC:30 1 :20
## Median :19.2 2 :20
## Mean :18.8
## 3rd Qu.:25.3
## Max. :33.9
ggplot(data = ToothGrowth, aes(x = dose, y = len, fill = supp)) + geom_bar(stat = "identity") + facet_grid(. ~ supp) + xlab("Dose in miligrams") + ylab("Numeric Tooth lenght")
t.test(len ~ supp, paired = F, var.equal = F, data = ToothGrowth)
##
## Welch Two Sample t-test
##
## data: len by supp
## t = 1.915, df = 55.31, p-value = 0.06063
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.171 7.571
## sample estimates:
## mean in group OJ mean in group VC
## 20.66 16.96