--- title: "Titanic Data" author: "Aditi Gupta" date: "March 1, 2018" output: html_document --- ```{r} setwd("~/Aditi/Sameer Mathur") titanic.df <- read.csv(paste("Titanic Data.csv", sep="")) library(psych) View(titanic.df) ``` Comments: 889 obs. of 8 variables is available for viewing as part of titanic dataframe ```{r} length(titanic.df$Survived) ``` Comments: Total number of passengers on board = 889 ```{r} table(titanic.df$Survived) ``` Comments: Total 340 passengers survived sinking of Titanic ```{r} mytable <- with(titanic.df, table(Survived)) prop.table(mytable)*100 ``` ```{r} mytable <- xtabs (~Survived+Pclass, data=titanic.df) mytable ```` Comments: the number of first-class passengers who survived the sinking of the Titanic is 134 ```{r} mytable <- xtabs (~Survived+Pclass, data=titanic.df) prop.table(mytable)*100 ```` Comments: 15% of first-class passengers survived the sinking of the Titanic ```{r} mytable <- xtabs(~Sex+Pclass, data=titanic.df) mytable ```` Comments: 92 females from First-Class survived the sinking of the Titanic ```{r} mytable <- xtabs (~Survived+Sex, data=titanic.df) prop.table(mytable)*100 ```` Comments: 25.984% of survivors were female ```{r} mytable <- xtabs (~Sex+Survived, data=titanic.df) prop.table(mytable)*100 ```` Comments: 25.984% of females on board the Titanic survived ```{r} mytable <- xtabs(~Sex+Survived, data=titanic.df) addmargins(mytable) chisq.test(mytable) ```` Comments: P-value is very less so we reject the null hypothesis 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