titanic.df <- read.csv("Titanic Data.csv")
sv = factor(titanic.df$Survived, levels = c(0,1), labels = c("Not_Survived", "Survived"))
aggregate(titanic.df$Age, by=list(Survived = sv), mean)
## Survived x
## 1 Not_Survived 30.41530
## 2 Survived 28.42382
Null hypothesis: There is no age differnce in suvivors and people who died in the titanic accident.
Alternate hypothesis: The titanic survivors were younger than the passengers who died.
t.test(titanic.df$Age~sv)
##
## Welch Two Sample t-test
##
## data: titanic.df$Age by sv
## t = 2.1816, df = 667.56, p-value = 0.02949
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.1990628 3.7838912
## sample estimates:
## mean in group Not_Survived mean in group Survived
## 30.41530 28.42382
p-value: 0.02949
From the above test we can see that the p-value is less than 0.05. So, we reject the null hypothesis that there is no difference in age of survivors and people who died.