Log in: http://rstudio.saintannsny.org:8787/

Electronic Version of this Lab

Previous Labs: dplyr, ggplot2

Cheat Sheets: Data Wrangling, ggplot, R Markdown

The Assignment

Your task is to write a report, describing what characteristics made someone more likely to survived the sinking of the Titanic. You should write this report using R Markdown. Start by going to “File/New File/R Markdown …” within the R menu. Title your report (you can change this later) and make the default output format HTML. In your first section of R code, you should load the dplyr and ggplot packages and read in the data. You may use the following block of code, which also creates three new variables, as your first R chunk.

.libPaths("/home/rstudioshared")
library(dplyr)
library(ggplot2)
titanic <- read.csv("/home/rstudioshared/shared_files/titanic_train.csv")

titanic <- titanic %>% mutate(Pclass.factor = as.factor(Pclass), 
                              Survived.factor = as.factor(Survived),
                              age.group = cut(Age, breaks=seq(0,90,10))
                              )

This should be a short report but it should include:

Save your R Markdown file as “titanicreport.Rmd” and, to see how it will look when you compile it, click “Knit HTML”. In addition to displaying your report in a pop-up window, this will also create a file entitled titanicreport.html in your home folder and this is the file that I will look at on Friday. You do not need to email me this file so long as you do this work on the Saint Ann’s server – I can simply view this file within your folder.