This is an assignment given on Week 2, Day 1 of the Data Analytics Internship under Prof. Sameer Mathur, IIML.
Recall the Titanic Data.csv data associated with the “Sinking of the RMS Titanic” that you analyzed on WEEK 1, DAY 5.Read the dataset into R.
setwd("C:/Users/Krushna/Downloads/UDEMY/T Test")
Titanic.df <- read.csv(paste("Titanic.csv", sep=""))
View(Titanic.df)
Use R to create a table showing the average age of the survivors and the average age of the people who died.
aggregate(Age~Survived,data=Titanic.df,FUN=mean)
Use R to run a t-test to test the following hypothesis: H2: The Titanic survivors were younger than the passengers who died. Thus our null hypothesis is : There is no significant difference between the age of the passengers who survived and those who died.
t.test(Age~Survived,data=Titanic.df)
The p-value obtained is less than 0.05. Hence, we reject our null hypothesis and conclude that the Titanic survivors were younger than the passengers who died.