I want to plot a KM curve and get median survival data from the survfit()
object but I don't want to split by strata - I want to know the whole population.
fit <- survfit(Surv(Time, Status) ~ Group, data = A)
eg. I don't want to have ~ Group
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)
If you don't want to see the confidence interval in the plot, then you should specify: conf.int=F
.