This is an assignment given on Week 2, Day 1 of the Data Analytics Internship under Prof. Sameer Mathur, IIML.

Task 4a

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)

Task 4b

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)

Task 4c

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.