Task 4a:Read Data

getwd()
## [1] "C:/Users/mahima tendulker/Desktop"
MyData<- read.csv(file="Titanic Data.csv", header=TRUE, sep=",")

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

seg.mean <- aggregate(Age ~ Survived, data=MyData, mean)
  seg.mean
##   Survived      Age
## 1        0 30.41530
## 2        1 28.42382

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

t.test(Age~Survived,data=MyData,alternative="less")
## 
##  Welch Two Sample t-test
## 
## data:  Age by Survived
## t = 2.1816, df = 667.56, p-value = 0.9853
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##      -Inf 3.495078
## sample estimates:
## mean in group 0 mean in group 1 
##        30.41530        28.42382

Here the value of P is >0.05. hence hypothesis is not rejected.