The Sinking of Titanic

This is a case study of the sinking of the Titanic.

Reading the data:

titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))
View(titanic.df)

Summary of the table:

Total number of passengers boarding the Titanic:

nrow(titanic.df)
library(psych)
describe(titanic.df$Survived)
mytable
mytable <-with(titanic.df, table(Survived))

Percentage of survivals:

prop.table(mytable)
prop.table(mytable)*100

Number of survivals by class:

mytable1 <- xtabs(~ Pclass, data = titanic.df)
mytable1

Number of survivals by class:

mytable2 <- xtabs(~ Pclass+Survived, data = titanic.df)
mytable2

Percentage of survivals by class:

prop.table(mytable2)
prop.table(mytable2)*100

Number of survivals by sex:

mytable3 <- xtabs(~ Survived+Sex, data = titanic.df)
mytable3

Number of 1st class survivals by sex:

mytable4 <- xtabs(~ Survived+Sex+Pclass, data = titanic.df)
mytable4

Percentage of 1st class survivals by sex:

prop.table(mytable4)
prop.table(mytable4)*100

Pearson’s chi-square test:

chisq.test(mytable3)