titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))
View(titanic.df)
library("psych", lib.loc="~/R/win-library/3.4")
Average age of the survivors and the average age of the people who died:
aggregate(titanic.df$Age, by=list(titanic.df$Survived), FUN=mean)
## Group.1 x
## 1 0 30.41530
## 2 1 28.42382
H2: The Titanic survivors were younger than the passengers who died.
t.test(titanic.df$Age, titanic.df$Survived, paired = TRUE)
##
## Paired t-test
##
## data: titanic.df$Age and titanic.df$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
Based on the above output of the t-test, we can reject the hypothesis that there is a significant difference between the age of passengers who survived as compared to the age of passengers who died.