Set global break.time.by value for ggsurvplot

Substitute manual "break.time.by" values with global which can be used
by all plots.
This commit is contained in:
Jens Sauer 2020-11-17 14:22:38 +01:00
parent c087b40f5c
commit 3c160c37bb
2 changed files with 9 additions and 4 deletions

View File

@ -17,7 +17,7 @@ surv_asct <- Surv(time = secmal$event_time_asct, event = secmal$event_status)
sma_plot_surv_dx <- function() {
ggsurvplot(survfit(surv_dx ~ 1), data = secmal, xscale = "d_y",
title = "Survival after diagnosis",
break.time.by = 5 * 365.25,
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw())
@ -28,7 +28,7 @@ sma_plot_surv_dx_sex <- function() {
ggsurvplot(survfit(surv_dx ~ sex, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after diagnosis",
legend.labs = c("Female", "Male"),
break.time.by = 5 * 365.25,
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw(),
@ -39,7 +39,7 @@ sma_plot_surv_dx_sex <- function() {
sma_plot_surv_asct <- function() {
ggsurvplot(survfit(surv_asct ~ 1), data = secmal, xscale = "d_y",
title = "Survival after transplantation",
break.time.by = 5 * 365.25,
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw())
@ -50,7 +50,7 @@ sma_plot_surv_asct_sex <- function() {
ggsurvplot(survfit(surv_asct ~ sex, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after transplantation",
legend.labs = c("Female", "Male"),
break.time.by = 5 * 365.25,
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw(),

View File

@ -73,3 +73,8 @@ sma_load_data <- function(file) {
return(sma)
}
#
# Global break.time.by value
#
sma_break.time.by = 5 * 365.25