[R] Legend positioning in scaled survival plot

From: Rachel Pearce <rachelpearce_at_msn.com>
Date: Thu 17 Mar 2005 - 23:41:30 EST

I am sorry that this is another novice question. I am having trouble using "legend" with the survival curve plot from the survival package, and I wonder if it is because I have rescaled my plot.

Here is the relevant segment of code:

> plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival by
+ xlab='Years',ylab='% surviving',lty=c(1,2),xscale=365.25,yscale=100)
> legend(5,80,c('Factor=1','Factor=2'),lty=c(1,2))

Here the variable OS is in days, but I want to plot it in years, so I scale it; likewise y is scaled to a percentage. I am trying to position the legend in the rescaled x and y values. Legend returns no error, but no legend appears on the plot.

If I exclude the scaling altogether:

> plot(survfit(Surv(OS,Status)~shortishcr1),main='Overall Survival by
+ xlab='Years',ylab='% surviving',lty=c(1,2),)
> legend(1825,.8,c('Factor=1','Factor=2'),lty=c(1,2))

then the legend appears exactly as expected.

Using the unscaled version of the legend call with the scaled plot, however, again no legend appears but no error is returned.

I suspect I am making some elementary mistake, but I just can't see it. It is so elementary that I can't find a similar question in the archives. Can someone help?

Here is my version information:

platform i386-pc-mingw32

arch     i386           
os       mingw32        
system   i386, mingw32  
major    2              
minor    0.1            
year     2004           
month    11             
day      15             

language R


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Mar 17 23:46:49 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:50 EST