require(datasets)
require(ggvis)
## Loading required package: ggvis
require(dplyr)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
require(magrittr)
## Loading required package: magrittr
require(xtable)
## Loading required package: xtable
require(htmlTable)
## Loading required package: htmlTable

1. Read a .csv file containing data elements about Titanic travelers from http://www.personal.psu.edu/dlp/w540/datasets/titanicsurvival.csv into an R dataset. These data might be available in other locations, but you must read this .csv file from the source provided here. This dataset contains four variables and has no missing data-

*Read data from web

titanic <- read.csv (file="http://www.personal.psu.edu/dlp/w540/datasets/titanicsurvival.csv", header = TRUE, sep=",")

titan1 <-tbl_df(titanic)
titan1
## Source: local data frame [2,201 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
htmlTable(head(titanic))
Class Age Sex Survive
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
4 1 1 1 1
5 1 1 1 1
6 1 1 1 1

*filter Class/Age/Sex/Survive

crew <- filter(titan1, Class == 0)
crew
## Source: local data frame [885 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     1       1
## 2      0     1     1       1
## 3      0     1     1       1
## 4      0     1     1       1
## 5      0     1     1       1
## 6      0     1     1       1
## 7      0     1     1       1
## 8      0     1     1       1
## 9      0     1     1       1
## 10     0     1     1       1
## ..   ...   ...   ...     ...
glimpse(crew)
## Observations: 885
## Variables: 4
## $ Class   (int) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(crew)
##      Class        Age         Sex           Survive      
##  Min.   :0   Min.   :1   Min.   :0.000   Min.   :0.0000  
##  1st Qu.:0   1st Qu.:1   1st Qu.:1.000   1st Qu.:0.0000  
##  Median :0   Median :1   Median :1.000   Median :0.0000  
##  Mean   :0   Mean   :1   Mean   :0.974   Mean   :0.2395  
##  3rd Qu.:0   3rd Qu.:1   3rd Qu.:1.000   3rd Qu.:0.0000  
##  Max.   :0   Max.   :1   Max.   :1.000   Max.   :1.0000
firstclass <- filter(titan1, Class == 1)
firstclass
## Source: local data frame [325 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
glimpse(firstclass)
## Observations: 325
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(firstclass)
##      Class        Age              Sex            Survive      
##  Min.   :1   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:1   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :1   Median :1.0000   Median :1.0000   Median :1.0000  
##  Mean   :1   Mean   :0.9815   Mean   :0.5538   Mean   :0.6246  
##  3rd Qu.:1   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  Max.   :1   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000
secondclass <- filter(titan1, Class == 2)
secondclass
## Source: local data frame [285 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     1       1
## 2      2     1     1       1
## 3      2     1     1       1
## 4      2     1     1       1
## 5      2     1     1       1
## 6      2     1     1       1
## 7      2     1     1       1
## 8      2     1     1       1
## 9      2     1     1       1
## 10     2     1     1       1
## ..   ...   ...   ...     ...
glimpse(secondclass)
## Observations: 285
## Variables: 4
## $ Class   (int) 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, ...
summary(secondclass)
##      Class        Age              Sex            Survive     
##  Min.   :2   Min.   :0.0000   Min.   :0.0000   Min.   :0.000  
##  1st Qu.:2   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:0.000  
##  Median :2   Median :1.0000   Median :1.0000   Median :0.000  
##  Mean   :2   Mean   :0.9158   Mean   :0.6281   Mean   :0.414  
##  3rd Qu.:2   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.000  
##  Max.   :2   Max.   :1.0000   Max.   :1.0000   Max.   :1.000
thirdclass <- filter(titan1, Class == 3)
thirdclass
## Source: local data frame [706 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     1       1
## 2      3     1     1       1
## 3      3     1     1       1
## 4      3     1     1       1
## 5      3     1     1       1
## 6      3     1     1       1
## 7      3     1     1       1
## 8      3     1     1       1
## 9      3     1     1       1
## 10     3     1     1       1
## ..   ...   ...   ...     ...
glimpse(thirdclass)
## Observations: 706
## Variables: 4
## $ Class   (int) 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(thirdclass)
##      Class        Age              Sex            Survive      
##  Min.   :3   Min.   :0.0000   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:3   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :3   Median :1.0000   Median :1.0000   Median :0.0000  
##  Mean   :3   Mean   :0.8881   Mean   :0.7224   Mean   :0.2521  
##  3rd Qu.:3   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  Max.   :3   Max.   :1.0000   Max.   :1.0000   Max.   :1.0000
adult<- filter(titan1, Age == 1)
adult
## Source: local data frame [2,092 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
glimpse(adult)
## Observations: 2,092
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(adult)
##      Class            Age         Sex            Survive      
##  Min.   :0.000   Min.   :1   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.000   1st Qu.:1   1st Qu.:1.0000   1st Qu.:0.0000  
##  Median :1.000   Median :1   Median :1.0000   Median :0.0000  
##  Mean   :1.301   Mean   :1   Mean   :0.7968   Mean   :0.3126  
##  3rd Qu.:3.000   3rd Qu.:1   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  Max.   :3.000   Max.   :1   Max.   :1.0000   Max.   :1.0000
child<- filter(titan1, Age == 0)
child
## Source: local data frame [109 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     1       1
## 2      1     0     1       1
## 3      1     0     1       1
## 4      1     0     1       1
## 5      1     0     1       1
## 6      1     0     0       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## ..   ...   ...   ...     ...
glimpse(child)
## Observations: 109
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...
## $ Age     (int) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(child)
##      Class           Age         Sex            Survive      
##  Min.   :1.00   Min.   :0   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:2.00   1st Qu.:0   1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :3.00   Median :0   Median :1.0000   Median :1.0000  
##  Mean   :2.67   Mean   :0   Mean   :0.5872   Mean   :0.5229  
##  3rd Qu.:3.00   3rd Qu.:0   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  Max.   :3.00   Max.   :0   Max.   :1.0000   Max.   :1.0000
male<- filter(titan1, Sex == 1)
male
## Source: local data frame [1,731 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
glimpse(male)
## Observations: 1,731
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(male)
##      Class            Age             Sex       Survive     
##  Min.   :0.000   Min.   :0.000   Min.   :1   Min.   :0.000  
##  1st Qu.:0.000   1st Qu.:1.000   1st Qu.:1   1st Qu.:0.000  
##  Median :1.000   Median :1.000   Median :1   Median :0.000  
##  Mean   :1.195   Mean   :0.963   Mean   :1   Mean   :0.212  
##  3rd Qu.:3.000   3rd Qu.:1.000   3rd Qu.:1   3rd Qu.:0.000  
##  Max.   :3.000   Max.   :1.000   Max.   :1   Max.   :1.000
female<- filter(titan1, Sex == 0)
female
## Source: local data frame [470 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
glimpse(female)
## Observations: 470
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(female)
##      Class            Age              Sex       Survive      
##  Min.   :0.000   Min.   :0.0000   Min.   :0   Min.   :0.0000  
##  1st Qu.:1.000   1st Qu.:1.0000   1st Qu.:0   1st Qu.:0.0000  
##  Median :2.000   Median :1.0000   Median :0   Median :1.0000  
##  Mean   :2.011   Mean   :0.9043   Mean   :0   Mean   :0.7319  
##  3rd Qu.:3.000   3rd Qu.:1.0000   3rd Qu.:0   3rd Qu.:1.0000  
##  Max.   :3.000   Max.   :1.0000   Max.   :0   Max.   :1.0000
survived<- filter(titan1, Survive == 1)
survived
## Source: local data frame [711 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
glimpse(survived)
## Observations: 711
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
summary(survived)
##      Class            Age              Sex            Survive 
##  Min.   :0.000   Min.   :0.0000   Min.   :0.0000   Min.   :1  
##  1st Qu.:0.000   1st Qu.:1.0000   1st Qu.:0.0000   1st Qu.:1  
##  Median :1.000   Median :1.0000   Median :1.0000   Median :1  
##  Mean   :1.368   Mean   :0.9198   Mean   :0.5162   Mean   :1  
##  3rd Qu.:2.500   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1  
##  Max.   :3.000   Max.   :1.0000   Max.   :1.0000   Max.   :1
died<- filter(titan1, Survive == 0)
died
## Source: local data frame [1,490 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       0
## 2      1     1     1       0
## 3      1     1     1       0
## 4      1     1     1       0
## 5      1     1     1       0
## 6      1     1     1       0
## 7      1     1     1       0
## 8      1     1     1       0
## 9      1     1     1       0
## 10     1     1     1       0
## ..   ...   ...   ...     ...
glimpse(died)
## Observations: 1,490
## Variables: 4
## $ Class   (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Age     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Sex     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
## $ Survive (int) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
summary(died)
##      Class            Age              Sex            Survive 
##  Min.   :0.000   Min.   :0.0000   Min.   :0.0000   Min.   :0  
##  1st Qu.:0.000   1st Qu.:1.0000   1st Qu.:1.0000   1st Qu.:0  
##  Median :1.000   Median :1.0000   Median :1.0000   Median :0  
##  Mean   :1.369   Mean   :0.9651   Mean   :0.9154   Mean   :0  
##  3rd Qu.:3.000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0  
##  Max.   :3.000   Max.   :1.0000   Max.   :1.0000   Max.   :0

2. Calculate the total number of passengers in the dataset.

passangercrew <- filter(titan1, Class>=0)
passangercrew
## Source: local data frame [2,201 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(passangercrew)
## [1] 2201
passangercrewNumber <- nrow(passangercrew)
passangercrewNumber
## [1] 2201

3. Calculate the total proportion of passengers surviving.

spassangercrew <- filter(survived,Class>=0)
spassangercrew
## Source: local data frame [711 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(spassangercrew)/nrow(titan1)
## [1] 0.323035
spassangercrewPortion <-nrow(spassangercrew)/nrow(titan1)
spassangercrewPortion 
## [1] 0.323035

4. Calculate the proportion of passengers surviving for each class of passenger.

crewspassanger <- filter(survived, Class==0)
crewspassanger
## Source: local data frame [212 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     1       1
## 2      0     1     1       1
## 3      0     1     1       1
## 4      0     1     1       1
## 5      0     1     1       1
## 6      0     1     1       1
## 7      0     1     1       1
## 8      0     1     1       1
## 9      0     1     1       1
## 10     0     1     1       1
## ..   ...   ...   ...     ...
nrow(crewspassanger)/nrow(crew)
## [1] 0.239548
crewspassangerPortion<-nrow(crewspassanger)/nrow(crew)
crewspassangerPortion
## [1] 0.239548
firstspassanger <- filter(survived, Class==1)
firstspassanger
## Source: local data frame [203 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(firstspassanger)/nrow(firstclass)
## [1] 0.6246154
firstspassangerPortion<-nrow(firstspassanger)/nrow(firstclass)
firstspassangerPortion
## [1] 0.6246154
secondspassanger <- filter(survived, Class==2)
secondspassanger
## Source: local data frame [118 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     1       1
## 2      2     1     1       1
## 3      2     1     1       1
## 4      2     1     1       1
## 5      2     1     1       1
## 6      2     1     1       1
## 7      2     1     1       1
## 8      2     1     1       1
## 9      2     1     1       1
## 10     2     1     1       1
## ..   ...   ...   ...     ...
nrow(secondspassanger)/nrow(secondclass)
## [1] 0.4140351
secondspassangerPortion<-nrow(secondspassanger)/nrow(secondclass)
secondspassangerPortion
## [1] 0.4140351
thirdspassanger <- filter(survived, Class==3)
thirdspassanger
## Source: local data frame [178 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     1       1
## 2      3     1     1       1
## 3      3     1     1       1
## 4      3     1     1       1
## 5      3     1     1       1
## 6      3     1     1       1
## 7      3     1     1       1
## 8      3     1     1       1
## 9      3     1     1       1
## 10     3     1     1       1
## ..   ...   ...   ...     ...
nrow(thirdspassanger)/nrow(thirdclass)
## [1] 0.2521246
thirdspassangerPortion<-nrow(thirdspassanger)/nrow(thirdclass)
thirdspassangerPortion
## [1] 0.2521246

5. Calculate the proportion of passengers surviving for each sex category. Which sex had the highest survival rate?

malespassanger <- filter(survived, Sex==1)
malespassanger
## Source: local data frame [367 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(malespassanger)/nrow(male)
## [1] 0.2120162
femalespassanger <- filter(survived, Sex==0)
femalespassanger
## Source: local data frame [344 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
nrow(femalespassanger)/nrow(female)
## [1] 0.7319149

summarise(group_by(female,Sex), survival_rate=nrow(malespassanger)/nrow(male) , nrow(femalespassanger)/nrow(female) ) ```

6. Calculate the proportion of passengers surviving for each age category. Which age had the lowest survival rate?

adultspassanger <- filter(survived, Age==1)
adultspassanger
## Source: local data frame [654 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(adultspassanger)/nrow(adult)
## [1] 0.3126195
childspassanger <- filter(survived, Age==0)
childspassanger
## Source: local data frame [57 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     1       1
## 2      1     0     1       1
## 3      1     0     1       1
## 4      1     0     1       1
## 5      1     0     1       1
## 6      1     0     0       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## ..   ...   ...   ...     ...
nrow(childspassanger)/nrow(child)
## [1] 0.5229358
summarise(group_by(child,Age), survival_rate=nrow(adultspassanger)/nrow(adult) , nrow(childspassanger)/nrow(child) )
## Source: local data frame [1 x 3]
## 
##     Age survival_rate nrow(childspassanger)/nrow(child)
##   (int)         (dbl)                             (dbl)
## 1     0     0.3126195                         0.5229358

7.Calculate the proportion of passengers surviving for each age/sex category (i.e., for adult males, child males, adult females, child females). Which group was most likely to survive? Least likely?

adultmale <-filter(titan1, Age==1, Sex==1)
adultmale
## Source: local data frame [1,667 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
adultmalespassanger<-filter(survived, Age==1, Sex==1)
adultmalespassanger
## Source: local data frame [338 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(adultmalespassanger)/nrow(adultmale)
## [1] 0.2027594
childmale <-filter(titan1, Age==0, Sex==1)
childmale
## Source: local data frame [64 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     1       1
## 2      1     0     1       1
## 3      1     0     1       1
## 4      1     0     1       1
## 5      1     0     1       1
## 6      2     0     1       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## ..   ...   ...   ...     ...
childmalespassanger<-filter(survived, Age==0, Sex==1)
childmalespassanger
## Source: local data frame [29 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     1       1
## 2      1     0     1       1
## 3      1     0     1       1
## 4      1     0     1       1
## 5      1     0     1       1
## 6      2     0     1       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## ..   ...   ...   ...     ...
nrow(childmalespassanger)/nrow(childmale)
## [1] 0.453125
adultfemale <-filter(titan1, Age==1, Sex==0)
adultfemale
## Source: local data frame [425 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
adultfemalespassanger<-filter(survived, Age==1, Sex==0)
adultfemalespassanger
## Source: local data frame [316 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
nrow(adultfemalespassanger)/nrow(adultfemale)
## [1] 0.7435294
childfemale <-filter(titan1, Age==0, Sex==0)
childfemale
## Source: local data frame [45 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     0       1
## 2      2     0     0       1
## 3      2     0     0       1
## 4      2     0     0       1
## 5      2     0     0       1
## 6      2     0     0       1
## 7      2     0     0       1
## 8      2     0     0       1
## 9      2     0     0       1
## 10     2     0     0       1
## ..   ...   ...   ...     ...
childfemalespassanger<-filter(survived, Age==0, Sex==0)
childfemalespassanger
## Source: local data frame [28 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     0     0       1
## 2      2     0     0       1
## 3      2     0     0       1
## 4      2     0     0       1
## 5      2     0     0       1
## 6      2     0     0       1
## 7      2     0     0       1
## 8      2     0     0       1
## 9      2     0     0       1
## 10     2     0     0       1
## ..   ...   ...   ...     ...
nrow(childfemalespassanger)/nrow(childfemale)
## [1] 0.6222222
Survival Rate
    1. Adult female passenger
nrow(adultfemalespassanger)/nrow(adultfemale)
## [1] 0.7435294
    1. Female children
nrow(childfemalespassanger)/nrow(childfemale)
## [1] 0.6222222
    1. Male children
nrow(childmalespassanger)/nrow(childmale)
## [1] 0.453125
    1. Adult male passenger
nrow(adultmalespassanger)/nrow(adultmale)
## [1] 0.2027594

8. Calculate the proportion of passengers surviving for each age/sex/class category. Which group had the highest mortality in this disaster. Why?

nrow(firstspassanger)/nrow(firstclass)
## [1] 0.6246154
firstadultmale <-filter(titan1, Class==1, Age==1, Sex==1)
firstadultmale
## Source: local data frame [175 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
firstadultmalespassanger<-filter(survived,Class==1, Age==1, Sex==1)
firstadultmalespassanger
## Source: local data frame [57 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     1       1
## 2      1     1     1       1
## 3      1     1     1       1
## 4      1     1     1       1
## 5      1     1     1       1
## 6      1     1     1       1
## 7      1     1     1       1
## 8      1     1     1       1
## 9      1     1     1       1
## 10     1     1     1       1
## ..   ...   ...   ...     ...
nrow(firstadultmalespassanger)/nrow(firstadultmale)
## [1] 0.3257143
firstchildmale <-filter(titan1, Class==1,Age==0, Sex==1)
firstchildmale
## Source: local data frame [5 x 4]
## 
##   Class   Age   Sex Survive
##   (int) (int) (int)   (int)
## 1     1     0     1       1
## 2     1     0     1       1
## 3     1     0     1       1
## 4     1     0     1       1
## 5     1     0     1       1
firstchildmalespassanger<-filter(survived, Class==1, Age==0, Sex==1)
firstchildmalespassanger
## Source: local data frame [5 x 4]
## 
##   Class   Age   Sex Survive
##   (int) (int) (int)   (int)
## 1     1     0     1       1
## 2     1     0     1       1
## 3     1     0     1       1
## 4     1     0     1       1
## 5     1     0     1       1
nrow(firstchildmalespassanger)/nrow(firstchildmale)
## [1] 1
firstadultfemale <-filter(titan1, Class==1,Age==1, Sex==0)
firstadultfemale
## Source: local data frame [144 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
firstadultfemalespassanger<-filter(survived,Class==1, Age==1, Sex==0)
firstadultfemalespassanger
## Source: local data frame [140 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      1     1     0       1
## 2      1     1     0       1
## 3      1     1     0       1
## 4      1     1     0       1
## 5      1     1     0       1
## 6      1     1     0       1
## 7      1     1     0       1
## 8      1     1     0       1
## 9      1     1     0       1
## 10     1     1     0       1
## ..   ...   ...   ...     ...
nrow(firstadultfemalespassanger)/nrow(firstadultfemale)
## [1] 0.9722222
firstchildfemale <-filter(titan1, Class==1,Age==0, Sex==0)
firstchildfemale
## Source: local data frame [1 x 4]
## 
##   Class   Age   Sex Survive
##   (int) (int) (int)   (int)
## 1     1     0     0       1
firstchildfemalespassanger<-filter(survived, Class==1,Age==0, Sex==0)
firstchildfemalespassanger
## Source: local data frame [1 x 4]
## 
##   Class   Age   Sex Survive
##   (int) (int) (int)   (int)
## 1     1     0     0       1
nrow(firstchildfemalespassanger)/nrow(firstchildfemale)
## [1] 1
nrow(secondspassanger)/nrow(secondclass)
## [1] 0.4140351
secondadultmale <-filter(titan1, Class==2, Age==1, Sex==1)
secondadultmale
## Source: local data frame [168 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     1       1
## 2      2     1     1       1
## 3      2     1     1       1
## 4      2     1     1       1
## 5      2     1     1       1
## 6      2     1     1       1
## 7      2     1     1       1
## 8      2     1     1       1
## 9      2     1     1       1
## 10     2     1     1       1
## ..   ...   ...   ...     ...
secondadultmalespassanger<-filter(survived,Class==2, Age==1, Sex==1)
secondadultmalespassanger
## Source: local data frame [14 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     1       1
## 2      2     1     1       1
## 3      2     1     1       1
## 4      2     1     1       1
## 5      2     1     1       1
## 6      2     1     1       1
## 7      2     1     1       1
## 8      2     1     1       1
## 9      2     1     1       1
## 10     2     1     1       1
## 11     2     1     1       1
## 12     2     1     1       1
## 13     2     1     1       1
## 14     2     1     1       1
nrow(secondadultmalespassanger)/nrow(secondadultmale)
## [1] 0.08333333
secondchildmale <-filter(titan1, Class==2,Age==0, Sex==1)
secondchildmale
## Source: local data frame [11 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     0     1       1
## 2      2     0     1       1
## 3      2     0     1       1
## 4      2     0     1       1
## 5      2     0     1       1
## 6      2     0     1       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## 11     2     0     1       1
secondchildmalespassanger<-filter(survived, Class==2, Age==0, Sex==1)
secondchildmalespassanger
## Source: local data frame [11 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     0     1       1
## 2      2     0     1       1
## 3      2     0     1       1
## 4      2     0     1       1
## 5      2     0     1       1
## 6      2     0     1       1
## 7      2     0     1       1
## 8      2     0     1       1
## 9      2     0     1       1
## 10     2     0     1       1
## 11     2     0     1       1
nrow(secondchildmalespassanger)/nrow(secondchildmale)
## [1] 1
secondadultfemale <-filter(titan1, Class==2,Age==1, Sex==0)
secondadultfemale
## Source: local data frame [93 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     0       1
## 2      2     1     0       1
## 3      2     1     0       1
## 4      2     1     0       1
## 5      2     1     0       1
## 6      2     1     0       1
## 7      2     1     0       1
## 8      2     1     0       1
## 9      2     1     0       1
## 10     2     1     0       1
## ..   ...   ...   ...     ...
secondadultfemalespassanger<-filter(survived,Class==2, Age==1, Sex==0)
secondadultfemalespassanger
## Source: local data frame [80 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     1     0       1
## 2      2     1     0       1
## 3      2     1     0       1
## 4      2     1     0       1
## 5      2     1     0       1
## 6      2     1     0       1
## 7      2     1     0       1
## 8      2     1     0       1
## 9      2     1     0       1
## 10     2     1     0       1
## ..   ...   ...   ...     ...
nrow(secondadultfemalespassanger)/nrow(secondadultfemale)
## [1] 0.8602151
secondchildfemale <-filter(titan1, Class==2,Age==0, Sex==0)
secondchildfemale
## Source: local data frame [13 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     0     0       1
## 2      2     0     0       1
## 3      2     0     0       1
## 4      2     0     0       1
## 5      2     0     0       1
## 6      2     0     0       1
## 7      2     0     0       1
## 8      2     0     0       1
## 9      2     0     0       1
## 10     2     0     0       1
## 11     2     0     0       1
## 12     2     0     0       1
## 13     2     0     0       1
secondchildfemalespassanger<-filter(survived, Class==2,Age==0, Sex==0)
secondchildfemalespassanger
## Source: local data frame [13 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      2     0     0       1
## 2      2     0     0       1
## 3      2     0     0       1
## 4      2     0     0       1
## 5      2     0     0       1
## 6      2     0     0       1
## 7      2     0     0       1
## 8      2     0     0       1
## 9      2     0     0       1
## 10     2     0     0       1
## 11     2     0     0       1
## 12     2     0     0       1
## 13     2     0     0       1
nrow(secondchildfemalespassanger)/nrow(secondchildfemale)
## [1] 1
nrow(thirdspassanger)/nrow(thirdclass)
## [1] 0.2521246
thirdadultmale <-filter(titan1, Class==3, Age==1, Sex==1)
thirdadultmale
## Source: local data frame [462 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     1       1
## 2      3     1     1       1
## 3      3     1     1       1
## 4      3     1     1       1
## 5      3     1     1       1
## 6      3     1     1       1
## 7      3     1     1       1
## 8      3     1     1       1
## 9      3     1     1       1
## 10     3     1     1       1
## ..   ...   ...   ...     ...
thirdadultmalespassanger<-filter(survived,Class==3, Age==1, Sex==1)
thirdadultmalespassanger
## Source: local data frame [75 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     1       1
## 2      3     1     1       1
## 3      3     1     1       1
## 4      3     1     1       1
## 5      3     1     1       1
## 6      3     1     1       1
## 7      3     1     1       1
## 8      3     1     1       1
## 9      3     1     1       1
## 10     3     1     1       1
## ..   ...   ...   ...     ...
nrow(thirdadultmalespassanger)/nrow(thirdadultmale)
## [1] 0.1623377
thirdchildmale <-filter(titan1, Class==3,Age==0, Sex==1)
thirdchildmale
## Source: local data frame [48 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     0     1       1
## 2      3     0     1       1
## 3      3     0     1       1
## 4      3     0     1       1
## 5      3     0     1       1
## 6      3     0     1       1
## 7      3     0     1       1
## 8      3     0     1       1
## 9      3     0     1       1
## 10     3     0     1       1
## ..   ...   ...   ...     ...
thirdchildmalespassanger<-filter(survived, Class==3, Age==0, Sex==1)
thirdchildmalespassanger
## Source: local data frame [13 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     0     1       1
## 2      3     0     1       1
## 3      3     0     1       1
## 4      3     0     1       1
## 5      3     0     1       1
## 6      3     0     1       1
## 7      3     0     1       1
## 8      3     0     1       1
## 9      3     0     1       1
## 10     3     0     1       1
## 11     3     0     1       1
## 12     3     0     1       1
## 13     3     0     1       1
nrow(thirdchildmalespassanger)/nrow(thirdchildmale)
## [1] 0.2708333
thirdadultfemale <-filter(titan1, Class==3,Age==1, Sex==0)
thirdadultfemale
## Source: local data frame [165 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     0       1
## 2      3     1     0       1
## 3      3     1     0       1
## 4      3     1     0       1
## 5      3     1     0       1
## 6      3     1     0       1
## 7      3     1     0       1
## 8      3     1     0       1
## 9      3     1     0       1
## 10     3     1     0       1
## ..   ...   ...   ...     ...
thirdadultfemalespassanger<-filter(survived,Class==3, Age==1, Sex==0)
thirdadultfemalespassanger
## Source: local data frame [76 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     1     0       1
## 2      3     1     0       1
## 3      3     1     0       1
## 4      3     1     0       1
## 5      3     1     0       1
## 6      3     1     0       1
## 7      3     1     0       1
## 8      3     1     0       1
## 9      3     1     0       1
## 10     3     1     0       1
## ..   ...   ...   ...     ...
nrow(thirdadultfemalespassanger)/nrow(thirdadultfemale)
## [1] 0.4606061
thirdchildfemale <-filter(titan1, Class==3,Age==0, Sex==0)
thirdchildfemale
## Source: local data frame [31 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     0     0       1
## 2      3     0     0       1
## 3      3     0     0       1
## 4      3     0     0       1
## 5      3     0     0       1
## 6      3     0     0       1
## 7      3     0     0       1
## 8      3     0     0       1
## 9      3     0     0       1
## 10     3     0     0       1
## ..   ...   ...   ...     ...
thirdchildfemalespassanger<-filter(survived, Class==3,Age==0, Sex==0)
thirdchildfemalespassanger
## Source: local data frame [14 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      3     0     0       1
## 2      3     0     0       1
## 3      3     0     0       1
## 4      3     0     0       1
## 5      3     0     0       1
## 6      3     0     0       1
## 7      3     0     0       1
## 8      3     0     0       1
## 9      3     0     0       1
## 10     3     0     0       1
## 11     3     0     0       1
## 12     3     0     0       1
## 13     3     0     0       1
## 14     3     0     0       1
nrow(thirdchildfemalespassanger)/nrow(thirdchildfemale)
## [1] 0.4516129
nrow(crewspassanger)/nrow(crew)
## [1] 0.239548
crewadultmale <-filter(titan1, Class==0, Age==1, Sex==1)
crewadultmale
## Source: local data frame [862 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     1       1
## 2      0     1     1       1
## 3      0     1     1       1
## 4      0     1     1       1
## 5      0     1     1       1
## 6      0     1     1       1
## 7      0     1     1       1
## 8      0     1     1       1
## 9      0     1     1       1
## 10     0     1     1       1
## ..   ...   ...   ...     ...
crewadultmalespassanger<-filter(survived,Class==0,Age==1,Sex==1)
crewadultmalespassanger
## Source: local data frame [192 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     1       1
## 2      0     1     1       1
## 3      0     1     1       1
## 4      0     1     1       1
## 5      0     1     1       1
## 6      0     1     1       1
## 7      0     1     1       1
## 8      0     1     1       1
## 9      0     1     1       1
## 10     0     1     1       1
## ..   ...   ...   ...     ...
nrow(crewadultmalespassanger)/nrow(crewadultmale)
## [1] 0.2227378
crewadultfemale <-filter(titan1, Class==0,Age==1, Sex==0)
crewadultfemale
## Source: local data frame [23 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     0       1
## 2      0     1     0       1
## 3      0     1     0       1
## 4      0     1     0       1
## 5      0     1     0       1
## 6      0     1     0       1
## 7      0     1     0       1
## 8      0     1     0       1
## 9      0     1     0       1
## 10     0     1     0       1
## ..   ...   ...   ...     ...
crewadultfemalespassanger<-filter(survived,Class==0, Age==1, Sex==0)
crewadultfemalespassanger
## Source: local data frame [20 x 4]
## 
##    Class   Age   Sex Survive
##    (int) (int) (int)   (int)
## 1      0     1     0       1
## 2      0     1     0       1
## 3      0     1     0       1
## 4      0     1     0       1
## 5      0     1     0       1
## 6      0     1     0       1
## 7      0     1     0       1
## 8      0     1     0       1
## 9      0     1     0       1
## 10     0     1     0       1
## 11     0     1     0       1
## 12     0     1     0       1
## 13     0     1     0       1
## 14     0     1     0       1
## 15     0     1     0       1
## 16     0     1     0       1
## 17     0     1     0       1
## 18     0     1     0       1
## 19     0     1     0       1
## 20     0     1     0       1
nrow(crewadultfemalespassanger)/nrow(crewadultfemale)
## [1] 0.8695652

9. Write a summary of your findings. Your summary may contain no more than 60 words.

Survival rate by groups

*1-1 Second Class Child Female:100.00%(13/13).

*1-2. Second Class Child Male: 100.00%(11/11).

*1-3. First Class Child Male: 100.00%(5/5).

*1-4. First Class Child Female: 100.00%(1/1).

*5. First Class Adult Female: 97.22% (140/144).

*6. Crew Adult Female: 86.96% (20/23).

*7. Second Class Adult Female: 86.02%(80/93).

*8. Third Class Adult Female: 46.06%(76/165).

*9. Third Class ChildFemale:45.16% (14/31).

*10. First Class Adult Male: 32.57% (57/175).

*11. Third Class Child Male: 27.08% (13/48).

*12. Crew Adult Male: 22.27% (192/862).

*13. Third Class Adult Male: 16.23% (75/462).

*14. Second Class Adult Male: 8.33% (14/168).

My major finding is that the survival rate for passengers on the Titanic depends on three parameters: class, age and sex. In order to compare the survival rates, passengers were divided into fourteen groups based on the three parameters above. The survival rate of first and second class children(male, female) is 100%. However, the sample number is too small. The sample only includes 13 second class female children, 11 second class male children , 5 first class male children and 1 first class female children. Among the groups whose sample number is larger than 20, the first class adult female survival rate is the highest (97.22%). The adult female crew members have the second highest survival rate (86.96%). The second class adult females have the third highest survival rate (86.02%). All the other groups’ survival rate is less than 50%. The groups with the lowest survival rates are as follows: the second class adult males (8.33%) , the third class adult males (16.23%), and adult male crew members (22.27%). Overall, from these statistics, I deduced that children and females were saved primarily. Nevertheless, it was possible that children and females in the third class were pushed back on the priority relief list. Among the adult male group, the firs class adult males’ survival rate is relatively higher than any other male adult group. (32.57%) From the fact, I inferred that the first class male adult passengers were considered priority number two right after children and females.