| title: Harvard business case study Project based on Titanic ship case analysis underguidance |
| of Prof sameer mathur PHD (IIM-Lucknow) |
| author: “krishna chaitanya rao (student intern jan01-jan27 batch)” |
| date: “January 7, 2018” |
| output: html_document |
titanic.df <- read.csv(paste(“Titanic Data.csv”, sep=“”))
View(titanic.df)
table(titanic.df$Survived)
myfile <- with(titanic.df,table(Survived)) prop.table(mytable)*100
myfile <- xtabs(~Survived + Pclass, data=titanic.df) myfile
prop.table(myfile,2)*100
myfile <- xtabs(~Survived + Pclass + Sex, data=titanic.df) myfile
myfile <- xtabs(~Survived+Sex, data=titanic.df) prop.table(myfile,2)*100
myfile<-xtabs(~Survived+Sex, data=titanic.df) prop.table(myfile,1)*100
chisq.test(prop.table(myfile))
chisq.test(myfile)
—————Project based on Titanic ship case analysis—————–
—————Sinking of the RMS-Titanic project under guidance of Prof sameer mathur (Phd)——–
1) Read the data using read.csv
titanic.df <- read.csv(paste(“Titanic Data.csv”, sep=“”))
2) View the data frame in R
View(titanic.df)
2a)To find the exact rows for the csv file
nrow(titanic.df) [1] 889
3)TO find the number of passengers who survived the sinking of the titanic.
table(titanic.df$Survived)
0 1 549 340 > > #4)measure the percentage of passengers who survived the sinking of the titanic > myfile <- with(titanic.df,table(Survived)) > prop.table(mytable)100 Pclass Survived 1 2 3 0 8.998875 10.911136 41.844769 1 15.073116 9.786277 13.385827 > > #5)number of first class passengers survived the sinking. > myfile <- xtabs(~Survived + Pclass, data=titanic.df) > myfile Pclass Survived 1 2 3 0 80 97 372 1 134 87 119 > > #6)percentage of first class passengers who survived the sinking of the titanic > prop.table(myfile,2)100 Pclass Survived 1 2 3 0 37.38318 52.71739 75.76375 1 62.61682 47.28261 24.23625 > > #7) number of females from First-Class who survived the sinking of the Titanic > myfile <- xtabs(~Survived + Pclass + Sex, data=titanic.df) > myfile , , Sex = female
Pclass
Survived 1 2 3 0 3 6 72 1 89 70 72
, , Sex = male
Pclass
Survived 1 2 3 0 77 91 300 1 45 17 47
8)measure the percentage of survivors who were female.
myfile <- xtabs(~Survived+Sex, data=titanic.df) prop.table(myfile,2)*100 Sex Survived female male 0 25.96154 81.10919 1 74.03846 18.89081
9)measure the percentage of survivors on board about female.
myfile<-xtabs(~Survived+Sex, data=titanic.df) prop.table(myfile,1)*100 Sex Survived female male 0 14.75410 85.24590 1 67.94118 32.05882
10)chi-square test analysis.
chisq.test(prop.table(myfile))
Pearson's Chi-squared test with Yates' continuity correction
data: prop.table(myfile) X-squared = 5.7395e-33, df = 1, p-value = 1
Warning message: In chisq.test(prop.table(myfile)) : Chi-squared approximation may be incorrect > > chisq.test(myfile)
Pearson's Chi-squared test with Yates' continuity correction
data: myfile X-squared = 258.43, df = 1, p-value < 2.2e-16