This Project is given by Prof. Sameer Mathur (IIM Lucknow) during the Data Analytics and Science Internship. In this we are supposed to do the case study of Titanic to get a complete knowledge and hands-on R language.
Titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))
View(Titanic.df)
Total number of Passengers onbord : 889
MyTitanicTable<-xtabs( ~ Survived, data=Titanic.df)
addmargins(MyTitanicTable)
## Survived
## 0 1 Sum
## 549 340 889
Survived (1): 340
MyTitanicTable<-xtabs( ~ Survived, data=Titanic.df)
MyTitanicTable
## Survived
## 0 1
## 549 340
Percentage of Survived (1): 38.24%
MyTitanicTable<-xtabs( ~ Survived, data=Titanic.df)
prop.table(MyTitanicTable)*100
## Survived
## 0 1
## 61.75478 38.24522
First Class Passengers who Survived: 134
MyTitanicTable<-xtabs( ~ Pclass + Survived, data=Titanic.df)
ftable(MyTitanicTable)
## Survived 0 1
## Pclass
## 1 80 134
## 2 97 87
## 3 372 119
Percentage of First class passengers who survived is: 15.07%
MyTitanicTable<-xtabs( ~ Pclass + Survived, data=Titanic.df)
prop.table(ftable(MyTitanicTable))*100
## Survived 0 1
## Pclass
## 1 8.998875 15.073116
## 2 10.911136 9.786277
## 3 41.844769 13.385827
Persentage of First Class people survied out of 214 First class passengers is: 62.61%
MyTitanicTable<-xtabs( ~ Pclass + Survived, data=Titanic.df)
prop.table(ftable(MyTitanicTable),1)*100
## Survived 0 1
## Pclass
## 1 37.38318 62.61682
## 2 52.71739 47.28261
## 3 75.76375 24.23625
Number of First Class Females who were servived are: 89
MyTitanicTable<-xtabs( ~ Pclass + Sex + Survived, data=Titanic.df)
ftable(MyTitanicTable)
## Survived 0 1
## Pclass Sex
## 1 female 3 89
## male 77 45
## 2 female 6 70
## male 91 17
## 3 female 72 72
## male 300 47
The Number of female survivours were: 67.94%
MyTitanicTable<-xtabs(~ Survived + Sex, data=Titanic.df)
prop.table(ftable(MyTitanicTable),1)*100
## Sex female male
## Survived
## 0 14.75410 85.24590
## 1 67.94118 32.05882
Total number of Female who Survived: 74.03%
MyTitanicTable<-xtabs(~ Survived + Sex, data=Titanic.df)
prop.table(ftable(MyTitanicTable),2)*100
## Sex female male
## Survived
## 0 25.96154 81.10919
## 1 74.03846 18.89081
Since the p value is very very less we assume that our hypothesis is correct.
MyTitanicTable<-xtabs(~Sex + Survived, data=Titanic.df)
chisq.test(MyTitanicTable)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: MyTitanicTable
## X-squared = 258.43, df = 1, p-value < 2.2e-16