Load data/check data
data(sleep)
str(sleep)
## 'data.frame': 20 obs. of 3 variables:
## $ extra: num 0.7 -1.6 -0.2 -1.2 -0.1 3.4 3.7 0.8 0 2 ...
## $ group: Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
## $ ID : Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
see the distribution
library(lattice)
densityplot( ~ extra,
groups = group,
data = sleep,
auto.key = TRUE,
lty = c(1, 2),
plot.points = F,
type = "g",
xlab = "Sleeping time",
main = "Sleeping time dirfference between w/& w/o treatment")
run t.test
t.test(extra ~ group, data = sleep)
##
## Welch Two Sample t-test
##
## data: extra by group
## t = -1.8608, df = 17.776, p-value = 0.07939
## alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0
## 95 percent confidence interval:
## -3.3654832 0.2054832
## sample estimates:
## mean in group 1 mean in group 2
## 0.75 2.33
Due to t < 2, and p-value > 0.05, there’s no signifigance thus I can’t support my null my hypothesis, but 95 percent confidence interval included 0 so I can’t completely deny my null hypothesis