getwd()
## [1] "C:/Users/TANAY/Documents"
setwd('C:/Users/TANAY/Downloads')

titanic <- read.csv('Titanic Data.csv')
View(titanic)

temp <- titanic[,1]
temp1 <- length(temp)
temp1
## [1] 889
survived <- subset(titanic,Survived==1)
nrow(survived)
## [1] 340
table(titanic$Survived)
## 
##   0   1 
## 549 340
percent <- nrow(survived)/temp1
percent*100
## [1] 38.24522
fcsurvived <- subset(survived,Pclass==1)
nrow(fcsurvived)
## [1] 134
ans3e <- xtabs(~Pclass+Survived,data=titanic)
prop.table(ans3e)*100
##       Survived
## Pclass         0         1
##      1  8.998875 15.073116
##      2 10.911136  9.786277
##      3 41.844769 13.385827
ans3f <- xtabs(~Sex+Pclass+Survived,data=titanic)
ans3f
## , , Survived = 0
## 
##         Pclass
## Sex        1   2   3
##   female   3   6  72
##   male    77  91 300
## 
## , , Survived = 1
## 
##         Pclass
## Sex        1   2   3
##   female  89  70  72
##   male    45  17  47
ans3g <- xtabs(~Sex+Survived,data=titanic)
ans3g
##         Survived
## Sex        0   1
##   female  81 231
##   male   468 109
prop.table(ans3g)*100
##         Survived
## Sex              0         1
##   female  9.111361 25.984252
##   male   52.643420 12.260967
survfemale <- subset(survived,Sex=='female')
perfemale <- nrow(survfemale)/nrow(survived)
perfemale*100
## [1] 67.94118
females <- subset(titanic,Sex=='female')
femalessurv <- subset(females,Survived==1)
ans <- nrow(femalessurv)/nrow(females)
ans*100
## [1] 74.03846
ans3i <- xtabs(~Sex+Survived,titanic)
chisq.test(ans3i)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  ans3i
## X-squared = 258.43, df = 1, p-value < 2.2e-16

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.