Q1

titanic.df <- read.csv(paste("C:/Users/kogentix/Downloads/Internship docs/week1/Titanic Data.csv", sep=""))

#View(titanic.df)
tempTP <- titanic.df[,1]
length(tempTP)
## [1] 889

Q2

library(psych)
table(titanic.df$Survived=="1")
## 
## FALSE  TRUE 
##   549   340

Q3

prop.table(table(titanic.df$Survived=="1"))*100
## 
##    FALSE     TRUE 
## 61.75478 38.24522

Q4

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

Q5

prop.table(xtabs(~Survived+Pclass,data=titanic.df))*100
##         Pclass
## Survived         1         2         3
##        0  8.998875 10.911136 41.844769
##        1 15.073116  9.786277 13.385827

Q6

table<-xtabs(~Sex+Pclass+Survived,data=titanic.df)
ftable(table)
##               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

Q7

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

Q8

prop.table(table,1)*100
##         Survived
## Sex             0        1
##   female 25.96154 74.03846
##   male   81.10919 18.89081

Q9

chisq.test(table)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table
## X-squared = 258.43, df = 1, p-value < 2.2e-16