[R] 2 KM curves on the same plot

array chip
Wed, 30 Sep 2020 02:26:46 -0000

Hi Jim,

I tried the clip() function below, surprisingly it did not work! I read the R
help file and feel your script should work. To have a workable example, I used
the ovarian dataset in the survival package as an example:

ovarian1<-ovarian
ovarian1$fustat[ovarian$futime>450]<-0
ovarian1$futime[ovarian$futime>450]<-450

ovarian2<-subset(ovarian,futime>450)

fit1 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian1)
fit2 <- survfit(Surv(futime, fustat) ~ rx, data = ovarian2)

plot(fit1, xlim=c(0,1200), col = 1:2)
abline(v=450)
xylim<-par("usr")
clip(450,xylim[2],xylim[3],xylim[4])
lines(fit2, col = 3:4,lty=2)

I can still see that the extra horizontal line on the top.?

Can you or anyone have any suggestion what went wrong?

Thanks,

John


On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon <drjimlemon at
gmail.com> wrote: