titanic.df <- read.csv(paste("Titanic Data.csv",sp=""))
aggregate(titanic.df$Age,by=list(titanic.df$Survived),mean)
## Group.1 x
## 1 0 30.41530
## 2 1 28.42382
Average age of survivors= 28.42 Average age of people who died= 30.41
t.test(titanic.df$Survived,titanic.df$Age,paired=TRUE)
##
## Paired t-test
##
## data: titanic.df$Survived and titanic.df$Age
## 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:
## -30.12782 -28.41458
## sample estimates:
## mean of the differences
## -29.2712
Since, p-value is less than 0.05, we can reject the null hypothesis.