This is an R Markdown document showing a detailed analysis of Titanic Dataset.
setwd("D:/R Internship")
titanic.df<-read.csv(paste("Titanic Data.csv",sep = ""))
View(titanic.df)
sum(table(titanic.df))
## [1] 889
sum(table(titanic.df[titanic.df$Survived==1,]))
## [1] 340
tit_surv<-table(titanic.df$Survived)
tit_surv
##
## 0 1
## 549 340
prop.table(tit_surv)*100
##
## 0 1
## 61.75478 38.24522
mytable<-xtabs(~Pclass+Survived, data = titanic.df)
mytable
## Survived
## Pclass 0 1
## 1 80 134
## 2 97 87
## 3 372 119
prop.table(mytable,1)*100
## Survived
## Pclass 0 1
## 1 37.38318 62.61682
## 2 52.71739 47.28261
## 3 75.76375 24.23625
mytable1<-xtabs(~Sex+Pclass+Survived, data = titanic.df)
ftable(mytable1)
## Survived 0 1
## Sex Pclass
## female 1 3 89
## 2 6 70
## 3 72 72
## male 1 77 45
## 2 91 17
## 3 300 47
mytable2<-xtabs(~Survived+Sex, data = titanic.df) #Task 3-g
prop.table(mytable2,1)*100
## Sex
## Survived female male
## 0 14.75410 85.24590
## 1 67.94118 32.05882
)
prop.table(mytable2,2)*100
## Sex
## Survived female male
## 0 25.96154 81.10919
## 1 74.03846 18.89081
chisq.test(mytable2)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: mytable2
## X-squared = 258.43, df = 1, p-value < 2.2e-16