death = read.csv("Titanic.csv")
On April 14, 1912 the Titanic set sail to the Americas from Southampton, England. The massive ship carried 1,313, all whom were distributed between its three classes. The data provides the name of the passangers, class, age, sex (0=male and 1=female) and if they survived. The zero represents death while one represent those who survived. We are gonna compare the number of survivors based on what class they were in.
class<-(death$PClass)
age<-(death$Age)
sex<-(death$Sex)
surv<-(death$Survived)
group<-(death$Survived)
dead<-death[which(group=="0"),]
alive<-death[which(group=="1"),]
#barplot to compare survival rates and class
par(mfrow=c(1,2))
d1<-table(dead$PClass)
a1<-table(alive$PClass)
barplot(d1, main="Deaths Per Class")
barplot(a1, main="Alive per Class")
summary(dead$PClass)
## * 1st 2nd 3rd
## 1 129 160 573
summary(alive$PClass)
## * 1st 2nd 3rd
## 0 193 119 138
According to my statistical discoveries, it can be proven that a greater amount of individuals from 3rd class died when the Titanic sunk. It can be predicted that this is due to the fact that it was more difficult for these individuals to find a way out of the ship. From the third class 373 individuals died while only 138 were able to survive.
#Creating a pie chart that I can see the proportion of passangers who survived from each class (1st, 2nd and 3rd)
par(mfrow=c(1,2))
slices<-c(129,160,573)
labels<-c("1st", "2nd", "3rd")
pie(slices, labels, main = "Pie Chart of Deathsh")
slices<-c(193,119,138)
labels<-c("1st", "2nd", "3rd")
pie(slices, labels, main="Pie Chart of Alive")
It is clearly seen in the pie chart that represents deaths from the Titanic that a greater loss was present in passengers from the third class. Although the distribution of survivors is fairly equal, almost half of those that survived are 1st class passengers.
As stated in my introduction, the purpose of this paper was to examine if there was a correlation between death and passenger class on the titanic. According to my statistical analysis, I have proven that there is a link between death rate and passenger class. There is a higher death rate among those who were 1st and 2nd class passengers.