Re: [R] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
Hi John, Brilliant solution and the best sort - when you finally solve your problem by yourself. Jim On Thu, Oct 1, 2020 at 2:52 AM array chip wrote: > > Hi Jim, > > I found out why clip() does not work with lines(survfit.object)! > > If you look at code of function survival:::lines.survfit, in

Re: [R] 2 KM curves on the same plot

2020-09-30 Thread array chip via R-help
Hi Jim, I found out why clip() does not work with lines(survfit.object)! If you look at code of function survival:::lines.survfit, in th middle of the code:     do.clip <- getOption("plot.survfit")     if (!is.null(xx <- do.clip$plotclip))          clip(xx[1], xx[2], xx[3], xx[4]) This will re

Re: [R] 2 KM curves on the same plot

2020-09-30 Thread array chip via R-help
Thank you Jim for helping! Yes, I will try Mark's method. John On Wednesday, September 30, 2020, 01:47:55 AM PDT, Jim Lemon wrote: Hi John, Hmmm, this works: plot(1:10) xylim<-par("usr") clip(5,xylim[2],xylim[3],xylim[4]) lines(10:1) so I suspect that there is a "lines" method that resets

Re: [R] 2 KM curves on the same plot

2020-09-30 Thread Jim Lemon
Hi John, Hmmm, this works: plot(1:10) xylim<-par("usr") clip(5,xylim[2],xylim[3],xylim[4]) lines(10:1) so I suspect that there is a "lines" method that resets the clipping region out of sight. Fortunately Mark Schwartz provided a way to get your plot so I will give the wall against which I have b

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread array chip via R-help
Jim, I tried a few things, I found that clip() works if I just do some regular graphing tasks. But as long as I run lines(fit) with "fit" object is a survfit object, this would reset to default plot region. See the ovarian example below: library(survival) ovarian1<-ovarian ovarian1$fustat[ovari

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread array chip via R-help
Hi Jim, I tried points(-1,-1) before lines() and before clip(), but either way, it still shows everything, :-( It's interesting that the examples with hist() provided by the R help of clip function works nicely. I also tried a simple linear regression plots below, clip() works, too. dat<-data

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread Jim Lemon
Hi John, I should have remembered this. For some reason, the clip() function doesn't operate until you have issued a graphics command. Try: points(-1,-1) before calling lines() Jim On Wed, Sep 30, 2020 at 12:26 PM array chip wrote: > > Hi Jim, > > I tried the clip() function below, surprisingl

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread array chip via R-help
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$futim

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread array chip via R-help
Thank you Marc as well! I'll try both ways! Yes this is an oncology study with time set at 5 John On Tuesday, September 29, 2020, 07:08:39 AM PDT, Marc Schwartz wrote: Hi John, >From the looks of the first plot, it would appear that perhaps you are engaged >in a landmark analysis in a

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread array chip via R-help
Thank you very much Jim, this is great!! John On Tuesday, September 29, 2020, 01:35:48 AM PDT, Jim Lemon wrote: Hi John, Perhaps the most direct way would be: plot(fit1, col=1:2) xylim<-par("usr") clip(4,xylim[2],xylim[3],xylim[4]) lines(fit2,col=1:2) Remember that the new clipping rec

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread Marc Schwartz via R-help
Hi John, >From the looks of the first plot, it would appear that perhaps you are engaged >in a landmark analysis in an oncology setting, with the landmark time set at 5 >years. On the off chance that you are not familiar with the pros and cons of >that methodology, Google "landmark analysis", w

Re: [R] 2 KM curves on the same plot

2020-09-29 Thread Jim Lemon
Hi John, Perhaps the most direct way would be: plot(fit1, col=1:2) xylim<-par("usr") clip(4,xylim[2],xylim[3],xylim[4]) lines(fit2,col=1:2) Remember that the new clipping rectangle will persist until you or something else resets it. Jim On Tue, Sep 29, 2020 at 10:34 AM array chip via R-help wr