Skip to contents

The sRtr package provides tools to load, label, and work with the Scientific Registry of Transplant Recipients (SRTR) Standard Analysis Files (SAFs) in R. It supports automatic variable labeling and factor conversion using the official SRTR data dictionary.

Installation

You can install the development version of sRtr from GitHub with:

# install.packages("devtools")
devtools::install_github("VagishHemmige/sRtr")

Setup

Before using load_srtr_file(), you must initialize the file registry using your local file paths:

library(sRtr)

# Example: point to a folder of .sas7bdat or .parquet files for the session only
set_srtr_wd("path/to/srtr/files")

# Or set permanently:
set_srtr_wd("path/to/srtr/files", permanent = TRUE)

Example

The primary function is load_srtr_file(), which loads and (optionally) labels SRTR files:

# Load the TX_LI file with factor and variable labels
tx_li <- load_srtr_file("TX_LI", factor_labels = TRUE, var_labels = TRUE)

# View factor labels
str(tx_li$DON_RACE)  # Example factor column

# View variable label
labelled::var_label(tx_li$DON_RACE)

You can also use the labeling functions independently:

df <- read_sas("TX_KI.sas7bdat")

df <- apply_srtr_factors(df, filekey="TX_KI")
df <- apply_srtr_varlabels(df, filekey="TX_KI")

If the name of the data frame corresponds to the name of the underlying file, then the filekey option can be omitted:

TX_KI <- read_sas("TX_KI.sas7bdat")

TX_KI_labelled <-TX_KI%>% 
  apply_srtr_factors()

See Function Reference for full documentation.

Much more, including help files, vignettes, etc. will be coming soon!