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

TASK 4b

Use R to create a table showing the average age of the survivors and the average age of the people who died.

average.age<-aggregate(titanic$Age,list(titanic$Survived),mean)
average.age
##   Group.1        x
## 1       0 30.41530
## 2       1 28.42382

Hence the average age of survivors was 28.4238 and the people who died was 30.4153.

TASK 4c

Use R to run a t-test to test the following hypothesis: H2: The Titanic survivors were younger than the passengers who died.

t.test(average.age,var.equal=TRUE)
## 
##  One Sample t-test
## 
## data:  average.age
## t = 1.7893, df = 3, p-value = 0.1715
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -11.64783  41.56739
## sample estimates:
## mean of x 
##  14.95978

p-value=0.1715 As p-value>0.05 Therefore there is no significant difference between the two populatione i.e. age and survived.Hence we accept the null hypothesis.And say that survived and age is dependant.