## Loading required package: ggvis
## 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
## 
## Loading required package: magrittr
## Loading required package: titanic1
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'titanic1'

2.Total Number of Passengers in the Dataset

summarise(titanic1, count=n())
##   count
## 1  2201

3. Calculate the total proportion of passengers surviving

titanic1 %>% group_by(Survive) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [2 x 3]
## 
##   Survive    n     freq
## 1       0 1490 0.676965
## 2       1  711 0.323035

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

titanic1 %>% group_by(Survive, Class) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [8 x 4]
## Groups: Survive
## 
##   Survive Class   n       freq
## 1       0     0 673 0.45167785
## 2       0     1 122 0.08187919
## 3       0     2 167 0.11208054
## 4       0     3 528 0.35436242
## 5       1     0 212 0.29817159
## 6       1     1 203 0.28551336
## 7       1     2 118 0.16596343
## 8       1     3 178 0.25035162

5. Calculate the proportion of passengers surviving for each sex category

titanic1 %>% group_by(Survive, Sex) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [4 x 4]
## Groups: Survive
## 
##   Survive Sex    n       freq
## 1       0   0  126 0.08456376
## 2       0   1 1364 0.91543624
## 3       1   0  344 0.48382560
## 4       1   1  367 0.51617440

6. Calculate the proportion of passengers surviving for each age category

titanic1 %>% group_by(Survive, Age) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [4 x 4]
## Groups: Survive
## 
##   Survive Age    n       freq
## 1       0   0   52 0.03489933
## 2       0   1 1438 0.96510067
## 3       1   0   57 0.08016878
## 4       1   1  654 0.91983122

7. Calculate the proportion of passengers surviving for each age/sex category

titanic1 %>% group_by(Survive, Age, Sex) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [8 x 5]
## Groups: Survive, Age
## 
##   Survive Age Sex    n       freq
## 1       0   0   0   17 0.32692308
## 2       0   0   1   35 0.67307692
## 3       0   1   0  109 0.07579972
## 4       0   1   1 1329 0.92420028
## 5       1   0   0   28 0.49122807
## 6       1   0   1   29 0.50877193
## 7       1   1   0  316 0.48318043
## 8       1   1   1  338 0.51681957

8 Calculate the Proportion for each age/sex/class category

titanic1 %>% group_by(Survive, Age, Sex, Class) %>% summarise (n=n()) %>% mutate (freq= n/sum(n))
## Source: local data frame [24 x 6]
## Groups: Survive, Age, Sex
## 
##    Survive Age Sex Class   n       freq
## 1        0   0   0     3  17 1.00000000
## 2        0   0   1     3  35 1.00000000
## 3        0   1   0     0   3 0.02752294
## 4        0   1   0     1   4 0.03669725
## 5        0   1   0     2  13 0.11926606
## 6        0   1   0     3  89 0.81651376
## 7        0   1   1     0 670 0.50413845
## 8        0   1   1     1 118 0.08878856
## 9        0   1   1     2 154 0.11587660
## 10       0   1   1     3 387 0.29119639
## ..     ... ... ...   ... ...        ...