For this project, I created a Kaplan-Meier survival plot from the results of a a double-blinded randomized trial on patients with primary biliary cirrhosis (PBC) of the liver was conducted at the Mayo clinic in 1984.
All credit for dataset go the Mayo clinic investigators. This is an adaptation of the plot that I created for my Statistical Methods in Public Health III course in spring 2023.
Code can be found below.
library(tidyverse)
library(survival)
library(survminer)
library(janitor)
pbcData = read_csv("pbctrial.csv")
pbcData$SurvObj = with(pbcData, Surv(survyr, death == 1))
km.drug = survfit(SurvObj ~ drug, data = pbcData,
type="kaplan-meier", conf.type="log-log")
centr = theme_classic() + theme(plot.title = element_text(hjust = 0.5, face = "bold"), axis.title.x = element_text(size = 15),
axis.title.y = element_text(size = 15))
ggsurvplot(km.drug, risk.table = TRUE, xlab = "Time in Years", title = "Kaplan-Meier Survival Plot: Effect of D-penicillin on Cirrhosis of Liver", ggtheme=centr)