Loaded packages that will be used

library(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
library(openxlsx)
library(readr)
library(utils)
library(haven)

1- Imported Titanic Data set

webcsv <- read.csv("http://www.personal.psu.edu/dlp/w540/titanic540.csv")

2-Converted Data set to a Tibble

webcsv.titanic <- tbl_df(webcsv)
webcsv.titanic
# A tibble: 1,309 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1 female    29     0     0 211.34        S
 2      1        1   male     1     1     2 151.55        S
 3      1        0 female     2     1     2 151.55        S
 4      1        0   male    30     1     2 151.55        S
 5      1        0 female    25     1     2 151.55        S
 6      1        1   male    48     0     0  26.55        S
 7      1        1 female    63     1     0  77.96        S
 8      1        0   male    39     0     0   0.00        S
 9      1        1 female    53     2     0  51.48        S
10      1        0   male    71     0     0  49.50        C
# ... with 1,299 more rows

3-Calculated the Porportion of Surviving Passengers

webcsv.titanic$survived
   [1] 1 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1
  [35] 0 1 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 1 1
  [69] 1 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0
 [103] 1 1 1 0 0 1 1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0
 [137] 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 0
 [171] 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0
 [205] 1 0 0 1 1 1 0 0 0 1 1 0 1 0 1 1 1 0 0 0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 0 0 0 0 1 0 0 0 0 1 1 1
[1191] 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1
[1225] 0 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 1
[1259] 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0
[1293] 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
webcsv.titanic.freq <- table(webcsv.titanic$survived)
webcsv.titanic.freq

  0   1 
809 500 
cbind(webcsv.titanic.freq)
  webcsv.titanic.freq
0                 809
1                 500
nrow(webcsv.titanic.freq)
[1] 2
webcsv.titanic.freq.2 <- webcsv.titanic.freq / nrow(webcsv.titanic.freq)
webcsv.titanic.freq.2

    0     1 
404.5 250.0 

4-Calculated the Proportion of Surviving Passengers by Sex

y <- c(webcsv$survived)
y
   [1] 1 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 1
  [35] 0 1 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 1 1
  [69] 1 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 0
 [103] 1 1 1 0 0 1 1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0
 [137] 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 1 1 0 1 1 0
 [171] 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0
 [205] 1 0 0 1 1 1 0 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 0 1 0 1 0 0
 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1 1 2 2 2
webcsv.prop.surv.sex <- table(x,y)
webcsv.prop.surv.sex
   y
x     0   1
  1 127 339
  2 682 161
ftable(webcsv.prop.surv.sex)
  y   0   1
x          
1   127 339
2   682 161

5-Calculated the Mean Age of Surviving Female Passengers

titanic.age.surv.fem <- filter(webcsv.titanic, sex =="female", survived =="1")
titanic.age.surv.fem
# A tibble: 339 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1 female    29     0     0 211.34        S
 2      1        1 female    63     1     0  77.96        S
 3      1        1 female    53     2     0  51.48        S
 4      1        1 female    18     1     0 227.53        C
 5      1        1 female    24     0     0  69.30        C
 6      1        1 female    26     0     0  78.85        S
 7      1        1 female    50     0     1 247.52        C
 8      1        1 female    32     0     0  76.29        C
 9      1        1 female    47     1     1  52.55        S
10      1        1 female    42     0     0 227.53        C
# ... with 329 more rows
titanic.age.surv.fem.2 <- select(titanic.age.surv.fem, age, survived, sex)
titanic.age.surv.fem.2
# A tibble: 339 x 3
     age survived    sex
   <int>    <int> <fctr>
 1    29        1 female
 2    63        1 female
 3    53        1 female
 4    18        1 female
 5    24        1 female
 6    26        1 female
 7    50        1 female
 8    32        1 female
 9    47        1 female
10    42        1 female
# ... with 329 more rows
mean.titanic.age <- mean(titanic.age.surv.fem.2$age, na.rm = TRUE)
mean.titanic.age
[1] 29.81849

6-Calculated the Number of Surviving Passengers 10 Years or Younger

surv.age.10 <- filter(webcsv.titanic, age<= 10, survived=="1")
surv.age.10
# A tibble: 50 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1   male     1     1     2 151.55        S
 2      1        1   male     4     0     2  81.86        S
 3      1        1   male     6     0     2 134.50        C
 4      2        1   male     1     2     1  39.00        S
 5      2        1 female     4     2     1  39.00        S
 6      2        1   male     1     0     2  29.00        S
 7      2        1 female     8     0     2  26.25        S
 8      2        1   male     8     1     1  36.75        S
 9      2        1   male     8     0     2  32.50        S
10      2        1   male     1     1     1  14.50        S
# ... with 40 more rows
surv.age.10.2 <- select(surv.age.10, age, survived)
surv.age.10.2
# A tibble: 50 x 2
     age survived
   <int>    <int>
 1     1        1
 2     4        1
 3     6        1
 4     1        1
 5     4        1
 6     1        1
 7     8        1
 8     8        1
 9     8        1
10     1        1
# ... with 40 more rows
surv.age.10.2 <- tbl_df(surv.age.10.2)
surv.age.10.2
# A tibble: 50 x 2
     age survived
   <int>    <int>
 1     1        1
 2     4        1
 3     6        1
 4     1        1
 5     4        1
 6     1        1
 7     8        1
 8     8        1
 9     8        1
10     1        1
# ... with 40 more rows
nrow(surv.age.10.2)
[1] 50

7-Calculated the Maximum, Minimum, and Median of Surviving Passengers 10 Years

or older

surv.age.10.older <- filter(webcsv.titanic, age>= 10, survived=="1")
surv.age.10.older
# A tibble: 377 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1 female    29     0     0 211.34        S
 2      1        1   male    48     0     0  26.55        S
 3      1        1 female    63     1     0  77.96        S
 4      1        1 female    53     2     0  51.48        S
 5      1        1 female    18     1     0 227.53        C
 6      1        1 female    24     0     0  69.30        C
 7      1        1 female    26     0     0  78.85        S
 8      1        1   male    80     0     0  30.00        S
 9      1        1 female    50     0     1 247.52        C
10      1        1 female    32     0     0  76.29        C
# ... with 367 more rows
surv.age.10.older.2 <- select(surv.age.10.older, age, survived)
surv.age.10.older.2
# A tibble: 377 x 2
     age survived
   <int>    <int>
 1    29        1
 2    48        1
 3    63        1
 4    53        1
 5    18        1
 6    24        1
 7    26        1
 8    80        1
 9    50        1
10    32        1
# ... with 367 more rows
surv.age.10.older.2 <- tbl_df(surv.age.10.older.2)
surv.age.10.older.2
# A tibble: 377 x 2
     age survived
   <int>    <int>
 1    29        1
 2    48        1
 3    63        1
 4    53        1
 5    18        1
 6    24        1
 7    26        1
 8    80        1
 9    50        1
10    32        1
# ... with 367 more rows
surv.age.10.older.2.sum <- surv.age.10.older.2 %>%
  summarise(min.age=min(age, na.rm=TRUE),
            max.age=max(age, na.rm=TRUE),
            median.age=median(age, na.rm=TRUE))
surv.age.10.older.2.sum
# A tibble: 1 x 3
  min.age max.age median.age
    <dbl>   <dbl>      <int>
1      11      80         30

8-Calculated the Proportion of Surviving Passengers by Port of Embarkation

surv.port <- filter(webcsv.titanic, survived=="1")
surv.port
# A tibble: 500 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1 female    29     0     0 211.34        S
 2      1        1   male     1     1     2 151.55        S
 3      1        1   male    48     0     0  26.55        S
 4      1        1 female    63     1     0  77.96        S
 5      1        1 female    53     2     0  51.48        S
 6      1        1 female    18     1     0 227.53        C
 7      1        1 female    24     0     0  69.30        C
 8      1        1 female    26     0     0  78.85        S
 9      1        1   male    80     0     0  30.00        S
10      1        1 female    50     0     1 247.52        C
# ... with 490 more rows
surv.port.2 <- select(surv.port, survived, embarked)
surv.port.2
# A tibble: 500 x 2
   survived embarked
      <int>   <fctr>
 1        1        S
 2        1        S
 3        1        S
 4        1        S
 5        1        S
 6        1        C
 7        1        C
 8        1        S
 9        1        S
10        1        C
# ... with 490 more rows
surv.port.2 <- tbl_df(surv.port.2)
surv.port.2
# A tibble: 500 x 2
   survived embarked
      <int>   <fctr>
 1        1        S
 2        1        S
 3        1        S
 4        1        S
 5        1        S
 6        1        C
 7        1        C
 8        1        S
 9        1        S
10        1        C
# ... with 490 more rows
surv.port.2.arr <- surv.port.2 %>%
  arrange(embarked)
surv.port.2.arr
# A tibble: 500 x 2
   survived embarked
      <int>   <fctr>
 1        1         
 2        1         
 3        1        C
 4        1        C
 5        1        C
 6        1        C
 7        1        C
 8        1        C
 9        1        C
10        1        C
# ... with 490 more rows
surv.port.2.arr <- table(webcsv.titanic$embarked)
surv.port.2.arr

      C   Q   S 
  2 270 123 914 
cbind(surv.port.2.arr)
  surv.port.2.arr
                2
C             270
Q             123
S             914
nrow(surv.port.2.arr)
[1] 4
surv.port.2.arr.prop <- surv.port.2.arr/ nrow(surv.port.2.arr)
surv.port.2.arr.prop

            C      Q      S 
  0.50  67.50  30.75 228.50 

9-Calculated the Number of Surviving Female Passengers Over the

Age of 40 by Port of Embarkation

titanic.age.surv.fem.port <- filter(webcsv.titanic, sex =="female", survived =="1", age> "40")
titanic.age.surv.fem.port
# A tibble: 74 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1 female    63     1     0  77.96        S
 2      1        1 female    53     2     0  51.48        S
 3      1        1 female    50     0     1 247.52        C
 4      1        1 female    47     1     1  52.55        S
 5      1        1 female    42     0     0 227.53        C
 6      1        1 female    58     0     0  26.55        S
 7      1        1 female    45     0     0 262.38        C
 8      1        1 female    44     0     0  27.72        C
 9      1        1 female    59     2     0  51.48        S
10      1        1 female    60     0     0  76.29        C
# ... with 64 more rows
titanic.age.surv.fem.port.2 <- select(titanic.age.surv.fem.port, age, survived, sex,embarked)
titanic.age.surv.fem.port.2
# A tibble: 74 x 4
     age survived    sex embarked
   <int>    <int> <fctr>   <fctr>
 1    63        1 female        S
 2    53        1 female        S
 3    50        1 female        C
 4    47        1 female        S
 5    42        1 female        C
 6    58        1 female        S
 7    45        1 female        C
 8    44        1 female        C
 9    59        1 female        S
10    60        1 female        C
# ... with 64 more rows
titanic.age.surv.fem.port.2.tbl <- table(titanic.age.surv.fem.port.2$embarked)
titanic.age.surv.fem.port.2.tbl

    C  Q  S 
 1 30  0 43 

10-Calculated the Mean Fare that Passengers Paid by Port of Embarkation

titanic.fare.port <- select(webcsv.titanic, fare, embarked)
titanic.fare.port
# A tibble: 1,309 x 2
     fare embarked
    <dbl>   <fctr>
 1 211.34        S
 2 151.55        S
 3 151.55        S
 4 151.55        S
 5 151.55        S
 6  26.55        S
 7  77.96        S
 8   0.00        S
 9  51.48        S
10  49.50        C
# ... with 1,299 more rows
titanic.fare.port.2 <- titanic.fare.port %>%
  arrange(embarked)
titanic.fare.port.2
# A tibble: 1,309 x 2
     fare embarked
    <dbl>   <fctr>
 1  80.00         
 2  80.00         
 3  49.50        C
 4 227.53        C
 5 227.53        C
 6  69.30        C
 7 247.52        C
 8 247.52        C
 9  76.29        C
10  75.24        C
# ... with 1,299 more rows
titanic.fare.port.2.grp <- titanic.fare.port.2 %>%
  group_by(embarked) %>%
  summarise(mean.fare=mean(fare, na.rm=TRUE))
titanic.fare.port.2.grp
# A tibble: 4 x 2
  embarked mean.fare
    <fctr>     <dbl>
1           80.00000
2        C  62.33719
3        Q  12.40935
4        S  27.41963

11-Calculated Number of Surviving Passengers who had any Siblings/Spouses aboard

Titanic

surv.sib.spo <- filter(webcsv.titanic, survived=="1", sibsp>"0")
surv.sib.spo
# A tibble: 191 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1   male     1     1     2 151.55        S
 2      1        1 female    63     1     0  77.96        S
 3      1        1 female    53     2     0  51.48        S
 4      1        1 female    18     1     0 227.53        C
 5      1        1   male    37     1     1  52.55        S
 6      1        1 female    47     1     1  52.55        S
 7      1        1   male    25     1     0  91.08        C
 8      1        1 female    19     1     0  91.08        C
 9      1        1 female    59     2     0  51.48        S
10      1        1   male    11     1     2 120.00        S
# ... with 181 more rows
surv.sib.spo <- tbl_df(surv.sib.spo)
surv.sib.spo
# A tibble: 191 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1   male     1     1     2 151.55        S
 2      1        1 female    63     1     0  77.96        S
 3      1        1 female    53     2     0  51.48        S
 4      1        1 female    18     1     0 227.53        C
 5      1        1   male    37     1     1  52.55        S
 6      1        1 female    47     1     1  52.55        S
 7      1        1   male    25     1     0  91.08        C
 8      1        1 female    19     1     0  91.08        C
 9      1        1 female    59     2     0  51.48        S
10      1        1   male    11     1     2 120.00        S
# ... with 181 more rows
surv.sib.spo.2 <- select(surv.sib.spo, survived, sibsp)
surv.sib.spo.2
# A tibble: 191 x 2
   survived sibsp
      <int> <int>
 1        1     1
 2        1     1
 3        1     2
 4        1     1
 5        1     1
 6        1     1
 7        1     1
 8        1     1
 9        1     2
10        1     1
# ... with 181 more rows
surv.sib.spo.2.tbl <- table(surv.sib.spo.2)
surv.sib.spo.2.tbl
        sibsp
survived   1   2   3   4
       1 163  19   6   3

12-Calculated Number of Surviving Passengers who had any Parents/Children aboard

Titanic

surv.par.ch <- filter(webcsv.titanic, survived=="1", parch>"0")
surv.par.ch
# A tibble: 164 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1   male     1     1     2 151.55        S
 2      1        1 female    50     0     1 247.52        C
 3      1        1   male    37     1     1  52.55        S
 4      1        1 female    47     1     1  52.55        S
 5      1        1 female    22     0     1  55.00        S
 6      1        1   male    36     0     1 512.33        C
 7      1        1 female    58     0     1 512.33        C
 8      1        1   male    11     1     2 120.00        S
 9      1        1 female    14     1     2 120.00        S
10      1        1   male    36     1     2 120.00        S
# ... with 154 more rows
surv.par.ch <- tbl_df(surv.par.ch)
surv.par.ch
# A tibble: 164 x 8
   pclass survived    sex   age sibsp parch   fare embarked
    <int>    <int> <fctr> <int> <int> <int>  <dbl>   <fctr>
 1      1        1   male     1     1     2 151.55        S
 2      1        1 female    50     0     1 247.52        C
 3      1        1   male    37     1     1  52.55        S
 4      1        1 female    47     1     1  52.55        S
 5      1        1 female    22     0     1  55.00        S
 6      1        1   male    36     0     1 512.33        C
 7      1        1 female    58     0     1 512.33        C
 8      1        1   male    11     1     2 120.00        S
 9      1        1 female    14     1     2 120.00        S
10      1        1   male    36     1     2 120.00        S
# ... with 154 more rows
surv.par.ch.2 <- select(surv.par.ch, survived, parch)
surv.par.ch.2
# A tibble: 164 x 2
   survived parch
      <int> <int>
 1        1     2
 2        1     1
 3        1     1
 4        1     1
 5        1     1
 6        1     1
 7        1     1
 8        1     2
 9        1     2
10        1     2
# ... with 154 more rows
surv.par.ch.2.tbl <- table(surv.par.ch.2)
surv.sib.spo.2.tbl
        sibsp
survived   1   2   3   4
       1 163  19   6   3

13-Calculated the Mean Fare that Passengers Paid by Passenger Class

titanic.fare.class <- select(webcsv.titanic, fare, pclass)
titanic.fare.class
# A tibble: 1,309 x 2
     fare pclass
    <dbl>  <int>
 1 211.34      1
 2 151.55      1
 3 151.55      1
 4 151.55      1
 5 151.55      1
 6  26.55      1
 7  77.96      1
 8   0.00      1
 9  51.48      1
10  49.50      1
# ... with 1,299 more rows
titanic.fare.class.2 <- titanic.fare.class %>%
  arrange(pclass)
titanic.fare.class.2
# A tibble: 1,309 x 2
     fare pclass
    <dbl>  <int>
 1 211.34      1
 2 151.55      1
 3 151.55      1
 4 151.55      1
 5 151.55      1
 6  26.55      1
 7  77.96      1
 8   0.00      1
 9  51.48      1
10  49.50      1
# ... with 1,299 more rows
titanic.fare.class.2.grp <- titanic.fare.class.2 %>%
  group_by(pclass) %>%
  summarise(mean.fare=mean(fare, na.rm=TRUE))
titanic.fare.class.2.grp
# A tibble: 3 x 2
  pclass mean.fare
   <int>     <dbl>
1      1  87.50935
2      2  21.17928
3      3  13.30414

14-Calculated a Regular Frequency Distribution of the Number of Parents/Children

aboard the Titanic of Female Passenger

15-Calculated Number of Surviving Passengers who had any Parents/Children aboard

fem.par.ch <- select(webcsv.titanic, sex, parch)
fem.par.ch
# A tibble: 1,309 x 2
      sex parch
   <fctr> <int>
 1 female     0
 2   male     2
 3 female     2
 4   male     2
 5 female     2
 6   male     0
 7 female     0
 8   male     0
 9 female     0
10   male     0
# ... with 1,299 more rows
fem.par.ch.2 <- filter(fem.par.ch, sex=="female", parch>"0")
fem.par.ch.2
# A tibble: 173 x 2
      sex parch
   <fctr> <int>
 1 female     2
 2 female     2
 3 female     1
 4 female     1
 5 female     1
 6 female     1
 7 female     2
 8 female     2
 9 female     1
10 female     1
# ... with 163 more rows
fem.par.ch.2 <- table(fem.par.ch.2)
fem.par.ch.2
        parch
sex       1  2  3  4  5  6  9
  female 88 69  6  4  4  1  1
  male    0  0  0  0  0  0  0