#Task4A
setwd("C:/Users/Dixit/iim_internship/Week2")
Titanic <- read.csv(file="Titanic_Data.csv",head=TRUE,sep=",")
View(Titanic)
#task4B
Titanic$Survived = factor(Titanic$Survived, levels = c(0,1), labels = c("Died", "Survived"))
Tableformat = aggregate(Titanic$Age~Titanic$Survived,data=Titanic,FUN=mean)
Tableformat
##   Titanic$Survived Titanic$Age
## 1             Died    30.41530
## 2         Survived    28.42382
#Task4C

t.test(Titanic$Age~Titanic$Survived)
## 
##  Welch Two Sample t-test
## 
## data:  Titanic$Age by Titanic$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 Died mean in group Survived 
##               30.41530               28.42382
pVal <- t.test(Titanic$Age~Titanic$Survived)$p.value
pVal
## [1] 0.02948791
#The Titanic survivors were younger than the passengers who died.
#Null Hypothesis: There is no significance between the age of passengers who surivived and passengers who died.
#As pval is < 0.05 suggests a significant difference between the age of our sample passengers surivived and sample passengers died we would reject our null hypothesis.
#This means the Titanic survivors were younger than the passengers who died.