Authors
Affiliation

Hannah Rosenthal

Montefiore Medical Center

Vagish Hemmige

The code in this script imports libraries, initializes constants, and performs other such preparatory work for the main analysis.

Source code

The full R script is available at:

Libraries

The analysis relies on a set of open-source R packages for data management, cohort construction, visualization, and statistical modeling. These libraries were selected based on their stability, community support, and suitability for large-scale longitudinal health data.

Click to show/hide R Code
# Libraries necessary for the analysis

#File import libraries
library(haven)
library(readr)
library(readxl)

#File export libraries
library(writexl)

#Data management libraries
library(tidyverse)
library(labelled)
library(dplyr)
library(tidyr)
library(janitor)
library(purrr)
library(lubridate)
library(conflicted)

#Core library for the SRTR
library(sRtr)

#Flowchart libraries
library(strobe)
library(flowchart)

#Statistical modeling libraries
library(MatchIt)
library(survival)
library(MASS)
library(sandwich)
library(lmtest)


#Table libraries
library(gtsummary)
library(gt)

#Plotting libraries
library(ggplot2)
library(survminer)


#Use the conflicted package to ensure that the select and filter functions are not superseded
conflict_prefer("select", "dplyr")
conflict_prefer("filter", "dplyr")
conflict_prefer("lag", "dplyr")

The table below lists the required packages along with links to their primary documentation.

Required R Packages
Libraries used for data processing, visualization, and statistical modeling
Category R package Documentation
File import haven CRAN – haven
File import readr CRAN – readr
File import readxl CRAN – readxl
File export writexl CRAN – writexl
Data management tidyverse tidyverse.org
Data management labelled CRAN – labelled
Data management dplyr CRAN – dplyr
Data management tidyr CRAN – tidyr
Data management janitor CRAN – janitor
Data management purrr CRAN – purrr
Data management lubridate lubridate.tidyverse.org
Data management conflicted CRAN – conflicted
SRTR-specific sRtr GitHub – sRtr
Flowcharting strobe GitHub – strobe
Flowcharting flowchart CRAN – flowchart
Statistical modeling MatchIt CRAN – MatchIt
Statistical modeling survival CRAN – survival
Statistical modeling MASS CRAN – MASS
Statistical modeling sandwich CRAN – sandwich
Statistical modeling lmtest CRAN – lmtest
Tables gtsummary gtsummary documentation
Tables gt gt documentation
Plotting ggplot2 ggplot2.tidyverse.org
Plotting survminer CRAN – survminer