About the Incident

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.

1.Reading the Titanic Dataset

setwd("C:/Users/CJ With HP/Desktop/IIM Lucknow/Datasets")
titanic.df <- read.csv(paste("Titanic Data.csv",sep=""))
View(titanic.df)

2.Total number of passengers on board the Titanic.

nrow(titanic.df)
## [1] 889

Ans = 889

3. Number of passengers who survived the sinking of the Titanic..

mytable <- with(titanic.df,table(Survived))
addmargins(mytable)
## Survived
##   0   1 Sum 
## 549 340 889

Ans= 340

4. Percentage of passengers who survived the sinking of the Titanic.

prop.table(mytable)*100
## Survived
##        0        1 
## 61.75478 38.24522

Ans= 38.24

5. Number of first-class passengers who survived the sinking of the Titanic.

mytable <- xtabs(~Pclass+Survived,data=titanic.df)
mytable
##       Survived
## Pclass   0   1
##      1  80 134
##      2  97  87
##      3 372 119

Ans= 134

6. Percentage of first-class passengers who survived the sinking of the Titanic.

prop.table(mytable,1)*100
##       Survived
## Pclass        0        1
##      1 37.38318 62.61682
##      2 52.71739 47.28261
##      3 75.76375 24.23625

Ans= 62.61

7.Number of females from First-Class who survived the sinking of the Titanic

mytable <- xtabs(~Survived+Sex,data=titanic.df)
mytable
##         Sex
## Survived female male
##        0     81  468
##        1    231  109

Ans= 231

8.The percentage of survivors who were female

prop.table(mytable,1)*100
##         Sex
## Survived   female     male
##        0 14.75410 85.24590
##        1 67.94118 32.05882

Ans = 67.94

9.The percentage of females on board the Titanic who survived

prop.table(mytable,2)*100
##         Sex
## Survived   female     male
##        0 25.96154 81.10919
##        1 74.03846 18.89081

Ans= 74.03

10.Chi-Square Test

Hypothesis: The proportion of females onboard who survived the sinking of the Titanic was higher than the proportion of males onboard who survived the sinking of the Titanic.

chisq.test(mytable)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  mytable
## X-squared = 258.43, df = 1, p-value < 2.2e-16

p-value comes out to be significantly lower than 5%. Thus there is a significant relation between the two variables, and therefore we can conclude that The proportion of females onboard who survived the sinking of the Titanic was higher than the proportion of males onboard who survived the sinking of the Titanic.