Chris
Chris

Reputation: 409

Does ggsurvplot_combine() not support the calculation of p-values?

I would like to plot the survival of a single group against the survival of the entire population in a single Kaplan-Meier plot.

Version 1:

library(tidyverse)
library(survival)
library(survminer)

df <- data.frame(Time     = c(1, 3, 5, 8, 2, 4),
                 Censored = c(0, 1, 0, 1, 1, 0),
                 Group    = c('A', 'A', 'B', 'A', 'B', 'B'))

fit1 <- survfit(Surv(Time, Censored) ~ 1, data = df)
fit2 <- survfit(Surv(Time, Censored) ~ 1, data = subset(df, Group == 'B'))

ggsurvplot_combine(list('0' = fit1, 'B' = fit2), pval = TRUE)

The p-value is not displayed. Does ggsurvplot_combine() not support the calculation of p-values?

My current workaround is as follows. Version 2:

library(tidyverse)
library(survival)
library(survminer)

df <- data.frame(Time     = c(1, 3, 5, 8, 2, 4),
                 Censored = c(0, 1, 0, 1, 1, 0),
                 Group    = c('A', 'A', 'B', 'A', 'B', 'B'))

df1 <- df %>% mutate(Strata = '0')
df2 <- df %>% filter(Group == 'B') %>% mutate(Strata = 'B')
df3 <- rbind(df1, df2)

fit <- survfit(Surv(Time, Censored) ~ Strata, data = df3)

ggsurvplot(fit, pval = TRUE)

I would prefer using version 1, because it uses the dataset without the need to make copies of the data frame.

Upvotes: 0

Views: 161

Answers (0)

Related Questions