3
votes

I want to plot a KM curve and get median survival data from the survfit object but I dont want to split by a strata - I want to know the whole population.

fit <- survfit(Surv(Time, Status) ~ Group, data = A)

eg. I dont want to have ~ Group

many thanks

2

2 Answers

1
votes

You then fit a model of the intercept. I generated some example data to illustrate this.

library(survival)

df <- data.frame(Status=c(0,1,0,1,0,1,0,1,0,1,0,1), 
                 Time=c(30,10,15,30,3,1,14,30,28,30,20,30))

df$forKM <- with(df, Surv(Time, Status == 1))

fit <- survfit(forKM ~ 1, data = df)
plot(fit)

enter image description here

If you don't want to see the confidence interval in the plot, then you should specify: conf.int=F.

0
votes

You can try

fit <- survfit(Surv(Time, Status) ~ 1, data = A)