I am putting together a survival analysis that gets run through a shiny app, and as such the output will be changing frequently. I have code that is running the survival analysis, and then printing the summary at for every 26 months (randomly chosen number as of right now), and doing that 10 times.
km_fit <- survfit(Surv(Life_Time_Months, Is_Closed) ~ 1, data = My_Data)
summary(km_fit, times = c(25 * (1:10)))
The output of the summary looks approximately like this:
time n.risk n.event survival std.err lower 95% CI upper 95% CI
26 99910 19897 0.841 0.00104 0.839 0.843
52 72512 15084 0.704 0.00134 0.701 0.707
78 52153 10037 0.598 0.00150 0.595 0.601
104 39170 5106 0.534 0.00159 0.531 0.537
130 30783 3394 0.484 0.00165 0.481 0.487
156 24563 2404 0.444 0.00171 0.440 0.447
182 19351 1625 0.412 0.00176 0.408 0.415
208 15463 1154 0.385 0.00182 0.382 0.389
234 11924 796 0.363 0.00187 0.359 0.367
260 9179 512 0.346 0.00194 0.342 0.349
Instead of having 10 printed results at multiples of 26, I would really like just one result that has when the percentage of survival is at 0.5, or as close as possible.
How would I go about doing this?