titanic.df <- read.csv(paste("Titanic Data.csv",sep =""))
head(titanic.df)
##   Survived Pclass    Sex  Age SibSp Parch    Fare Embarked
## 1        0      3   male 22.0     1     0  7.2500        S
## 2        1      1 female 38.0     1     0 71.2833        C
## 3        1      3 female 26.0     0     0  7.9250        S
## 4        1      1 female 35.0     1     0 53.1000        S
## 5        0      3   male 35.0     0     0  8.0500        S
## 6        0      3   male 29.7     0     0  8.4583        Q
library("car", lib.loc="~/R/win-library/3.4")
some(titanic.df)
##     Survived Pclass    Sex  Age SibSp Parch    Fare Embarked
## 87         0      3   male 29.7     0     0  8.0500        S
## 140        0      3 female 29.7     0     2 15.2458        C
## 208        1      3 female 16.0     0     0  7.7500        Q
## 219        0      2   male 30.0     0     0 10.5000        S
## 357        0      2 female 38.0     0     0 13.0000        S
## 409        0      3 female 29.7     3     1 25.4667        S
## 459        0      3   male 29.7     0     0  7.7500        Q
## 518        1      2 female 36.0     1     0 26.0000        S
## 709        1      3   male 29.7     1     1 15.2458        C
## 734        0      2   male 23.0     0     0 13.0000        S
mytab <- aggregate(titanic.df$Age , by = list(titanic.df$Survived) , mean)
mytab
##   Group.1        x
## 1       0 30.41530
## 2       1 28.42382
t.test(titanic.df$Age~titanic.df$Survived)
## 
##  Welch Two Sample t-test
## 
## data:  titanic.df$Age by titanic.df$Survived
## 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 0 mean in group 1 
##        30.41530        28.42382

Since the p-value = 0.03(approx.) < 0.05 , so we can say that there is significant difference between the mean values of the ages of survivors and the people who drowned. So, we fail to reject the hypothesis H2.

Thanking you

Nihir Gulati