PART 3A

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

sum(table(titanic.df))
## [1] 889

PART 3B

sum(table(titanic.df[titanic.df$Survived==1,]))
## [1] 340

PART 3C

prop.table(table(titanic.df$Survived))*100
## 
##        0        1 
## 61.75478 38.24522

PART 3D

a1<-xtabs(~Survived+Pclass,data=titanic.df) #Task 3-d
a1
##         Pclass
## Survived   1   2   3
##        0  80  97 372
##        1 134  87 119

PART 3E

a2<-xtabs(~Survived+Pclass,data=titanic.df) #Task 3-e
prop.table(a2,2)*100
##         Pclass
## Survived        1        2        3
##        0 37.38318 52.71739 75.76375
##        1 62.61682 47.28261 24.23625

PART 3F

a3<-xtabs(~Sex+Survived+Pclass,data=titanic.df) 
ftable(a3)
##                 Pclass   1   2   3
## Sex    Survived                   
## female 0                 3   6  72
##        1                89  70  72
## male   0                77  91 300
##        1                45  17  47

PART 3G

a4<-xtabs(~Survived+Sex,data=titanic.df) 
prop.table(a4,1)*100
##         Sex
## Survived   female     male
##        0 14.75410 85.24590
##        1 67.94118 32.05882

PART 3H

a5<-xtabs(~Sex+Survived,data=titanic.df) 
prop.table(a5,1)*100 
##         Survived
## Sex             0        1
##   female 25.96154 74.03846
##   male   81.10919 18.89081

PART 3I

a6<-prop.table(a5,1)*100 
chisq.test(a6)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  a6
## X-squared = 58.934, df = 1, p-value = 1.631e-14