i hope the example will work.
i wanted to know if there is a way to extract the coordninates of EACH point od a survival curve.
i know from ?plot.survfit
that it will produce a values with the coordinates of the end of each class, but i would like to know all the points in which the line changes
library(survival)
status <- c(1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,0)
classification <- c(1,1,1,2,2,2,2,2,2,2,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8)
df <-data.frame( Sub = c(letters,LETTERS[1:24]),
status= status,
time= round(rnorm(50,300,100),0),
class = classification )
fit <- survfit(Surv(time, status)~class, data= df)
plotFit <- plot(fit)
i know i can extract the surv value from
fit$surv
, and that i can combine them with the fit$time
and fit$n.event
but from this matrix i had to create a cycle to create a point at every 90 degree turn when a status changes, so was wandering if there was a faster way to have directly the values of all those line turning points.
thanks in advance