titanic.df <- read.csv(paste("Titanic Data.csv",sep=""))
dim(titanic.df)
## [1] 889 8
by(titanic.df$Age,titanic.df$Survived,mean)
## titanic.df$Survived: 0
## [1] 30.4153
## --------------------------------------------------------
## titanic.df$Survived: 1
## [1] 28.42382
the average of age of people who survived and people who died in the sinking of RMS titanic.
H2: The Titanic survivors were younger than the passengers who died.
t.test(Age~Survived,var.equal=TRUE,data=titanic.df)
##
## Two Sample t-test
##
## data: Age by 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
as the p-value is greater than 0.01 we cannot reject the null hypothesis that the survivors were not younger than the passengers who died.