[R] 2 KM curves on the same plot
@rr@ypro|||e @end|ng |rom y@hoo@com
Wed Sep 30 04:26:46 CEST 2020
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:
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)
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?
On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon <drjimlemon using gmail.com> wrote:
Perhaps the most direct way would be:
Remember that the new clipping rectangle will persist until you or
something else resets it.
On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help
<r-help using r-project.org> wrote:
> Can anyone suggest a simple way to generate a Kaplan-Meier plot with 2 survfit objects, just like this one:
> Suppose I have 2 survfit objects: fit1 is for the curve on the left (survtime has been truncated to the cutoff line: year 5), fit2 is for the curve on the right (minimum survival time is at the cutoff line: year 5), but if I do the following:
> plot(fit1, col=1:2)
> Then I will have an horizontal line on the top that connect from 0 to 4 years, which I do not want that to be drawn (see blue arrow below):
> Can anyone have a strategy to make this kind of plot happen?
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help