This lesson is in the early stages of development (Alpha version)

R for Survival Analysis: Setup

This lesson assumes you have R and RStudio installed on your computer. The latest version of R can be downloaded here. RStudio is an application (an integrated development environment or IDE) that facilitates the use of R and offers a number of nice additional features. It can be downloaded here. You will need the free Desktop version for your computer.

The lesson is based on the Game of Thrones characters’ mortality dataset that was published here. Please save the following two files using File - Save As dialog in your browser.

  1. Original characters data
  2. Additional data encoding table

You can install all required R packages by running the following function in R console:

install_dependencies <- function () {
  dependencies <- c("dplyr",  "ggplot2", "survival", "survminer")
  installed <- installed.packages()
  to_install <- subset(dependencies, !(dependencies %in% installed[, "Package"]))
  if (length(to_install) != 0) {
    if (!requireNamespace("BiocManager", quietly = TRUE)) {
      install.packages("BiocManager")
    }
    message("Installing packages: ", to_install, " ...")
    BiocManager::install(to_install)
  } else {
    message("All dependencies are already installed.")
  }
}
install_dependencies()