titanic.df <- read.csv(paste("Titanic Data.csv"), sep= ",")
View(titanic.df)
nrow(titanic.df)
## [1] 889
nrow(subset(titanic.df,Survived==1))
## [1] 340
(prop.table(table(titanic.df$Survived))*100)[2]
##        1 
## 38.24522
mytable <- xtabs(~Survived+Pclass,data=titanic.df)
mytable[2]
## [1] 134
(prop.table(mytable)*100)[2]
## [1] 15.07312
female <- xtabs(~Survived+Pclass+Sex,data=titanic.df)
(ftable(female))[4]
## [1] 89
mytable <- xtabs(~Survived+Sex,data=titanic.df)
(prop.table(mytable,1)*100)[2,1]
## [1] 67.94118
(prop.table(mytable,2)*100)[2,1]
## [1] 74.03846
chisq.test(mytable)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  mytable
## X-squared = 258.43, df = 1, p-value < 2.2e-16