Titanic W2 D1

TASK 4a

titanic<- read.csv("Titanic Data.csv")

TASK 4b

Average age of survivours and died

aggregate(titanic$Age, by=list(Survived=titanic$Survived), mean)
##   Survived        x
## 1        0 30.41530
## 2        1 28.42382

TASK 4c

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

survivedTitanic<- titanic[which(titanic$Survived==1),]
diedTitanic<- titanic[which(titanic$Survived==0),]

t.test(survivedTitanic$Age,diedTitanic$Age)
## 
##  Welch Two Sample t-test
## 
## data:  survivedTitanic$Age and diedTitanic$Age
## 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:
##  -3.7838912 -0.1990628
## sample estimates:
## mean of x mean of y 
##  28.42382  30.41530

p-value < 0.05, This test shows there is significant difference in the age who survived and who died.