titanic <- read.csv("Titanic Data.csv")
View(titanic)
Table showing the average age of the survivors and the average age of the people who died.
aggregate(Age ~ Survived, data = titanic, mean)
## Survived Age
## 1 0 30.41530
## 2 1 28.42382
t-test to test the following hypothesis
t.test(titanic$Age,titanic$Survived,paired=TRUE)
##
## Paired t-test
##
## data: titanic$Age and titanic$Survived
## t = 67.065, df = 888, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 28.41458 30.12782
## sample estimates:
## mean of the differences
## 29.2712
p<0.05, hence we can reject the null hypothesis and accept the hypothesis that Titanic surviors were younger than the passengers who died by running a paired t-test.