Setting working directory

setwd("E:/Internship/Tasks/Week 2/Week 2, Day 1 (Mon)")

Creating Dataframe

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

Task 4(b) Creating table to showing the average age of survivor and average age of people who died

aggregate(titanic.df$Age, list(titanic.df$Survived), mean)
##   Group.1        x
## 1       0 30.41530
## 2       1 28.42382

Task 4(c) Running t-test

t.test(Age~Survived,data=titanic.df)
## 
##  Welch Two Sample t-test
## 
## data:  Age by Survived
## 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:
##  0.1990628 3.7838912
## sample estimates:
## mean in group 0 mean in group 1 
##        30.41530        28.42382

Hypothesis is true people who survived were younger since their avaerge age is 28.42382 and died people average is 30.41530 and p-value from t-test is 0.02949 which is less than 0.05