These are the Solution of the problems given in Titanic case Study.
titanic.df= read.csv("Titanic Data.csv")
View(titanic.df)
Question 1 Total number of passengers on board the Titanic.
Total= length(titanic.df[ ,1])
Total
## [1] 889
Question 2: Total number of passengers who survived the sinking of the Titanic.
survivor = subset(titanic.df, titanic.df$Survive == 1)
nrow(survivor)
## [1] 340
Question 3: The percentage of passengers who survived the sinking of the Titanic
Total=889
survivor= 340
percent= (340/889)*100
percent
## [1] 38.24522
Question 4: Use R to count the number of first-class passengers who survived the sinking of the Titanic
survivor_firstClass = subset(titanic.df, titanic.df$Survive == 1 & titanic.df$Pclass == 1)
(Sf = nrow(survivor_firstClass))
## [1] 134
Question 5: Use R to measure the percentage of first-class passengers who survived the sinking of the Titanic.
Total = 889
per= (134/889)*100
per
## [1] 15.07312
Question 6: Use R to count the number of females from First-Class who survived the sinking of the Titanic
survivor_firstClass_female = subset(titanic.df, titanic.df$Survive == 1 & titanic.df$Pclass == 1 & titanic.df$Sex == 'female')
nrow(survivor_firstClass_female)
## [1] 89
Question 7: Use R to measure the percentage of survivors who were female
femper=(89/889)*100
femper
## [1] 10.01125
Question 8: Use R to measure the percentage of females on board the Titanic who survived
femonboard=(89/889)*100
femonboard
## [1] 10.01125