titanic.df<-read.csv(paste("Titanic Data.csv",sep=""))
View(titanic.df)
aggregate(titanic.df$Age, by=list(titanic.df$Survived), 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,var.equal=TRUE)
##
## Two Sample t-test
##
## data: titanic.df$Age by titanic.df$Survived
## t = 2.2302, df = 887, p-value = 0.02599
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.238890 3.744064
## sample estimates:
## mean in group 0 mean in group 1
## 30.41530 28.42382
p-value = 0.02599 (p<0.05)
As p-value is less than 0.05, so we can reject the null hypothesis.Hence there is noticable difference between the ages of people who died and the ones who survived.