Analysis for Titanic Data

  1. Creation of a table showing the average age of the survivors and the average age of the people who died.
aggregate(tit.df$Age, by= list(tit.df$Survived), FUN= mean)
##   Group.1        x
## 1       0 30.41530
## 2       1 28.42382
  1. The average age of survivors is 28.42 years

  2. The average age of people who died is 30.41 years.

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

attach(tit.df)
t.test(Survived ,Age, paired =TRUE)
## 
##  Paired t-test
## 
## data:  Survived and Age
## t = -67.065, df = 888, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -30.12782 -28.41458
## sample estimates:
## mean of the differences 
##                -29.2712
  1. The p value is 2.2e-16

  2. Based on the above output of the test, we can reject the hypothesis that The tittanic survivors and people who died had same age.(p<.01)