1) The ‘titanic’ dataset

      titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))
      View(titanic.df)

2) The total number of passengers

    dim(titanic.df)
## [1] 889   8

We can see the total number of passengers is 889 as it is the number of rows in the datasheet.

3) The total number of passengers who survived the sinking of titanic

    table(titanic.df$Survived)
## 
##   0   1 
## 549 340

We can see that 340 passengers survived the sinking of the titanic

4) Percentage of passengers who survived the sinking

    prop.table(table(titanic.df$Survived))*100
## 
##        0        1 
## 61.75478 38.24522

From the above table we see that 38.24522 percent of the passengers survived.

5) Number of first class passengers who survived the sinking

    mytable<-xtabs(~Pclass + Survived, data=titanic.df)
    mytable
##       Survived
## Pclass   0   1
##      1  80 134
##      2  97  87
##      3 372 119
134 first class passengers survived the sinking

6) Percentage of first class passengers who survived the sinking

    prop.table(mytable,1)*100
##       Survived
## Pclass        0        1
##      1 37.38318 62.61682
##      2 52.71739 47.28261
##      3 75.76375 24.23625
From the data above it is clear that 62.6182% of the first class passengers survived

7) Number of females from first class who survived the sinking

    mytable1 <- xtabs(~Pclass+Survived+Sex, data=titanic.df)
    mytable1
## , , Sex = female
## 
##       Survived
## Pclass   0   1
##      1   3  89
##      2   6  70
##      3  72  72
## 
## , , Sex = male
## 
##       Survived
## Pclass   0   1
##      1  77  45
##      2  91  17
##      3 300  47
Using the 3 way contingency table we find that 89 female first class passengers survived the     sinking.

8) Percentage of Survivors that were female

    prop.table(xtabs(~Sex+Survived, data=titanic.df),2)*100
##         Survived
## Sex             0        1
##   female 14.75410 67.94118
##   male   85.24590 32.05882
  The percentage of survivors that were female is 67.94118
  

9) Percentage of females who survived

    prop.table(xtabs(~Sex+Survived, data=titanic.df),1)*100
##         Survived
## Sex             0        1
##   female 25.96154 74.03846
##   male   81.10919 18.89081
    The percentage of females who survived is 74.03846
    

10) Pearson’s Chi square test

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

Since we that the p value is very low and p<0.01 we can reject the null hypothesis