0

Want to add patient ID as labels to my survival plot. I know that I did not provide source data, sorry. But I guess, my problem could be solve anyway with you smart people ;-)

library(survival)

s=Surv(data$OS,data$Death.1)~data$Tumordignity

b=survfit(s)

plot(b, 
     col = c("darkred","darkgoldenrod","darkblue","green3"), 
     bty = "n", 
     lwd = 3, 
     mark.time = TRUE, 
     main="Overall survival in patients with malignancies",
     xlab="survival time...",
     ylab = "Survival rate...",
     xlim=c(0,2600),
     cex.main=0.8) 

#so far, so good...
# try to add text to the mark.time-points

text(data$OS,
 data$Death.1,
 labels = data$ID, 
 cex= 0.7, pos=3)

Problem with this, that labels (IDs) will be plotted in the right x position but not in the right y position. see my plot

How to fix it? Use points(x..)?

Squaleolus
  • 23
  • 1
  • 4

0 Answers0