Author
Affiliation

Vagish Hemmige

Montefiore Medical Center/ Albert Einstein College of Medicine

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

# Data management
library(tidyverse)
library(stringi)
library(glue)

#Core library for the SRTR
library(sRtr)

#Data import libraries
library(readxl)
library(readr)
library(haven)
library(mapboxapi)
library(CDCAtlas)

#Geographic libraries
library(sf)
library(tigris)
library(tidycensus)
library(tmap)
library(lutz)

#Table libraries
library(flextable)
library(gt)

#Plotting
library(colorspace)
library(ggtext)
library(extrafont)
library(janitor)
library(ggrepel)
library(writexl)
library(plotly)
library(htmlwidgets)
library(patchwork)
library(ggbeeswarm)
library(ggpubr)
library(cowplot)
library(scales)

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
Data management tidyverse tidyverse
Data management stringi stringi
Data management glue glue
SRTR-specific sRtr sRtr GitHub
Data import readxl readxl
Data import readr readr
Data import haven haven
Data import mapboxapi mapboxapi
Data import CDCAtlas CDCAtlas GitHub
Geographic sf sf
Geographic tigris tigris
Geographic tidycensus tidycensus
Geographic tmap tmap
Geographic lutz lutz
Tables flextable flextable
Tables gt gt
Plotting colorspace colorspace
Plotting ggtext ggtext
Plotting extrafont extrafont
Plotting janitor janitor
Plotting ggrepel ggrepel
Plotting writexl writexl
Plotting plotly plotly
Plotting htmlwidgets htmlwidgets
Plotting patchwork patchwork
Plotting ggbeeswarm ggbeeswarm
Plotting ggpubr ggpubr
Plotting cowplot cowplot
Plotting scales scales

Constants

A number of analysis parameters are reused across cohort construction, matching, and cost modeling steps.

These constants are defined in the R/setup.R file.

Click to show/hide R Code
organ_list<-c("liver", "kidney", "heart", "lung", "pancreas")
year_list<-c("2017", "2022")
distance_list=c("50mile", "60min", "100mile", "200mile")

#List states which are continental
continental_fips <- c(
  "01", "04", "05", "06", "08", "09", "10", "11", "12", "13", "16",
  "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
  "27", "28", "29", "30", "31", "32", "33", "34", "35", "36",
  "37", "38", "39", "40", "41", "42", "44", "45", "46", "47",
  "48", "49", "50", "51", "53", "54", "55", "56"
)

#For isochrone analysis, we need to account for time zones in order to calculate driving time at 7 AM on the specific date

#List US continental time zones

timezones<-c("America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Phoenix",
             "America/Indiana/Indianapolis","America/Kentucky/Louisville","America/Detroit")

reference_date<-list()

# Specific date to anchor the time: First Monday in March of both years
reference_date[["2022"]] <- as.Date("2022-03-07")
reference_date[["2017"]] <- as.Date("2017-03-06")

For clarity, these constants are summarized below along with brief explanations of their role in the analysis.

Analysis Constants
Geographic buffer definitions and time-zone parameters
Constant Value Explanation
organ_list liver, kidney, heart, lung, pancreas Organs included in transplant center access analysis
year_list 2017, 2022 Calendar years evaluated for geographic access comparison
distance_list 50mile, 60min, 100mile, 200mile Distance or drive-time buffers used to define transplant center catchment areas
continental_fips 01, 04, 05, 06, 08, 09, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56 FIPS codes representing continental U.S. states included in analysis
timezones America/New_York, America/Chicago, America/Denver, America/Los_Angeles, America/Phoenix, America/Indiana/Indianapolis, America/Kentucky/Louisville, America/Detroit Time zones used to convert local 7 AM departure times to UTC for isochrone calculations
reference_date 2022: 2022-03-07 | 2017: 2017-03-06 Anchor dates (first Monday in March) used for time-zone–adjusted isochrone generation

Other portions of the analysis

  • Functions: Reusable helper functions for cohort construction, matching, costing, and modeling.
  • Tables: Summary tables and regression outputs generated from the final models.
  • Figures:Visualizations of costs, risks, and model-based estimates.
  • About: methods, assumptions, and disclosures