1) Read the data using read.csv

titanic.df <- read.csv(“Titanic Data.csv”)

2) View the data frame

View(titanic.df)

3) Count the total number of passengers on board

dim(titanic.df)

4) Count the number of passengers who survived

table(titanic.df$Survived)

4) Measure the percentage total number of passengers who survived

prop.table(table(titanic.df$Survived))*100

5) Count the number of first-class passengers who survived

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

6) Measure the percentage of first-class passengers who survived

prop.table(table5,1)*100

7) Count the number of females from first-Class who survived

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

8) Measure the percentage of survivors who were female

table8<-xtabs(~Sex+Survived, data=titanic.df) prop.table(table8,2)*100

9) Measure the percentage of females who survived

table9<-xtabs(~Sex+Survived, data=titanic.df) prop.table(table9,1)*100

10) Pearson’s Chi-squared test

mytable10 <- xtabs(~Sex+Survived, data=titanic.df) mytable10 chisq.test(mytable10)