The sinking of the RMS Titanic occurred on the night of 14 April through to the morning of 15 April 1912 in the North Atlantic Ocean, four days into the ship’s maiden voyage from Southampton to New York City. The largest passenger liner in service at the time, Titanic had an estimated 2,224 people on board when she struck an iceberg at around 23:40 (ship’s time) on Sunday, 14 April 1912. Her sinking two hours and forty minutes later at 02:20 (05:18 GMT) on Monday, 15 April resulted in the deaths of more than 1,500 people, which made it one of the deadliest peacetime maritime disasters in history.
This is a R Markdown document highlighting some facts about the Titanic Data.
Recall the Titanic Data.csv data associated with the “Sinking of the RMS Titanic” that you analyzed on WEEK 1, DAY 5.
setwd("D:/manipal-year2/internship/IIML_dataAnalytics/Datasets")
titanic.df <- read.csv(paste("Titanic Data.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(titanic.df$Age,by=list(Survived = titanic.df$Survived),mean)
## Survived x
## 1 0 30.41530
## 2 1 28.42382
Use R to run a t-test to test the following hypothesis: Hint: The Titanic survivors were younger than the passengers who died.
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
The small p-value indicates that we can reject the null hypothesis that there is no significant difference in age of passengers that survived and died.
The t-test shows that the p-value is less that 0.05 and hence, there is a relationship between the age of the passenger and whether he survived or not.
The mean values prove that average age of passengers that died is higher than those of passengers that survived. Thus, the titanic survivors were younger than the passengers who died.