This is a statistical report on the sinking of the RMS Titanic, on 12 April 1912. For more information, please visit https://en.wikipedia.org/wiki/Sinking_of_the_RMS_Titanic.
Data set used is as follows:
setwd("C:\\Users\\Tejajay\\Desktop\\Internship\\3. Data Analytics")
titanic <- read.csv(paste("TitanicData.csv", sep=""))
The number of passengers that travelled on the Titanic:
length(titanic$Survived)
## [1] 889
Number of survivors on the Titanic:
mytable <- with(titanic, table(Survived))
View(mytable)
Percentage of survivors:
mytable <- with(titanic, table(Survived))
prop.table(mytable)*100
## Survived
## 0 1
## 61.75478 38.24522
Number of survivors by class:
mytable <- xtabs(~ Survived+Pclass, data=titanic)
View(mytable)
Percentage of survivors by class:
mytable <- xtabs(~ Survived+Pclass, data=titanic)
prop.table(mytable, 1)*100
## Pclass
## Survived 1 2 3
## 0 14.57195 17.66849 67.75956
## 1 39.41176 25.58824 35.00000
Percentage of female survivors:
mytable <- xtabs(~ Survived+Sex, data=titanic)
prop.table(mytable, 1)*100
## Sex
## Survived female male
## 0 14.75410 85.24590
## 1 67.94118 32.05882
Number of 1st class female survivors:
mytable <- xtabs(~ Survived+Pclass+Sex, data = titanic)
ftable(mytable)
## Sex female male
## Survived Pclass
## 0 1 3 77
## 2 6 91
## 3 72 300
## 1 1 89 45
## 2 70 17
## 3 72 47
Percentage of females who survived:
mytable <- xtabs(~ Sex+Survived, data=titanic)
prop.table(mytable, 1)*100
## Survived
## Sex 0 1
## female 25.96154 74.03846
## male 81.10919 18.89081
Pearson’s Chi-Squared Test:
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
The null-hypothesis made during the Pearson’s Chi-Squared test is that there is no difference between number of females and males surviving the sinking of the RMS Titanic. During the test, however, we obtain a p-value of 2.2e-16, which is extremely low. This means that we reject the null hypothesis. Thus, there is a relationship/dependence between the number of surviving males and females. From the above tables, we can see clearly that a much larger proportion of females survived the sinking, as compared to men.