g_km | R Documentation |
From a survival model, a graphic is rendered along with tabulated annotation including the number of patient at risk at given time and the median survival per group.
g_km(
df,
variables,
control_surv = control_surv_timepoint(),
col = NULL,
lty = NULL,
lwd = 0.5,
censor_show = TRUE,
pch = 3,
size = 2,
max_time = NULL,
xticks = NULL,
xlab = "Days",
yval = c("Survival", "Failure"),
ylab = paste(yval, "Probability"),
ylim = NULL,
title = NULL,
footnotes = NULL,
font_size = 10,
ci_ribbon = FALSE,
annot_at_risk = TRUE,
annot_at_risk_title = TRUE,
annot_surv_med = TRUE,
annot_coxph = FALSE,
annot_stats = NULL,
annot_stats_vlines = FALSE,
control_coxph_pw = control_coxph(),
ref_group_coxph = NULL,
control_annot_surv_med = control_surv_med_annot(),
control_annot_coxph = control_coxph_annot(),
legend_pos = NULL,
rel_height_plot = 0.75,
ggtheme = NULL,
as_list = FALSE,
draw = lifecycle::deprecated(),
newpage = lifecycle::deprecated(),
gp = lifecycle::deprecated(),
vp = lifecycle::deprecated(),
name = lifecycle::deprecated(),
annot_coxph_ref_lbls = lifecycle::deprecated(),
position_coxph = lifecycle::deprecated(),
position_surv_med = lifecycle::deprecated(),
width_annots = lifecycle::deprecated()
)
A ggplot
Kaplan-Meier plot and (optionally) summary table.
library(dplyr)
library(nestcolor)
df <- tern_ex_adtte %>%
filter(PARAMCD == "OS") %>%
mutate(is_event = CNSR == 0)
variables <- list(tte = "AVAL", is_event = "is_event", arm = "ARMCD")
# Basic examples
g_km(df = df, variables = variables)
g_km(df = df, variables = variables, yval = "Failure")
# Examples with customization parameters applied
g_km(
df = df,
variables = variables,
control_surv = control_surv_timepoint(conf_level = 0.9),
col = c("grey25", "grey50", "grey75"),
annot_at_risk_title = FALSE,
lty = 1:3,
font_size = 8
)
g_km(
df = df,
variables = variables,
annot_stats = c("min", "median"),
annot_stats_vlines = TRUE,
max_time = 3000,
ggtheme = ggplot2::theme_minimal()
)
# Example with pairwise Cox-PH analysis annotation table, adjusted annotation tables
g_km(
df = df, variables = variables,
annot_coxph = TRUE,
control_coxph = control_coxph(pval_method = "wald", ties = "exact", conf_level = 0.99),
control_annot_coxph = control_coxph_annot(x = 0.26, w = 0.35),
control_annot_surv_med = control_surv_med_annot(x = 0.8, y = 0.9, w = 0.35)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.