Importing the file:

titanic <- read.csv(paste("Titanic Data.csv", sep=""))

4b. table showing the average age of the survivors and the average age of the people who died

aggregate(Age~Survived,data=titanic,mean)
##   Survived      Age
## 1        0 30.41530
## 2        1 28.42382

4c. t-test to test the hypothesis H2:The Titanic survivors were younger than the passengers who died

The following will be the NULL Hyposthesis “H3:There is no significant difference between age of passengers who survived and passengers who died”

attach(titanic)
log.transformed.Age=log(Age)
t.test(log.transformed.Age~Survived,var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  log.transformed.Age by Survived
## t = 3.844, df = 887, p-value = 0.0001297
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.09102778 0.28094770
## sample estimates:
## mean in group 0 mean in group 1 
##        3.304318        3.118330

Since p-value is lesser than 0.05, we conclude that our NULL hypothesis H3 does not hold good.