3

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

tamtam
  • 3,541
  • 1
  • 7
  • 21
Crispin
  • 33
  • 3

2 Answers2

2

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.

milan
  • 4,782
  • 2
  • 21
  • 39
0

You can try:

fit <- survfit(Surv(Time, Status) ~ 1, data = A)
Mario
  • 1,631
  • 2
  • 21
  • 51
wxxyyyzz
  • 241
  • 1
  • 7