Reproducible Pitch Presentation

Andreas Schätti
January 30, 2017

Probability of survival of sinking of RMS Titanic

  • Task
    • Develop a shiny app where users can enter their data of a virtual trip on RMS Titanic and see their probability of surviving the sinking
    • A reactive component shall be implemented in the server part. This component shall react on changing input in the UI, do some calculation, and then display the result in the UI.
  • Check out the app!
  • Source code is available on GitHub

How to use the app (1/2)

  • In the sidebar, enter your data (or any other data you are interested in).
  • You could buy three types of tickets for the trip. I used the globally known class names from aviation:
    • 1st class = First
    • 2nd class = Business
    • 3rd class = Economy
  • Hit Update and the result is shown in the main panel.

How to use the app (2/2)

  • The predicted probability of your survival is shown in percent.
  • The actual survival for passengers with your data is shown as a bar plot.
  • If there are no passengers with your data, no prediction is possible.

Implementation details: server.R

There are 177 missing values for Age in the titanic dataset. These are input by randomly sampling existing values, separately by sex (only shown for females here):

n.samples <- sum(is.na.age & is.female)
sampled.age.female <- sample(
  titanic.data$Age[!is.na.age & is.female],
  n.samples,
  replace=TRUE)
titanic.data$Age[is.na.age & is.female] <-
  sampled.age.female
sum(is.na(titanic.data$Age) & is.female)
[1] 0