[R] Unable to get Legend with survplot rms package

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Oct 26 21:21:23 CET 2009


Aric Gregson wrote:
> Hello,
> 
> I apologize for the post as I am certainly overlooking a simple
> solution to my difficulties with getting a legend to print on a
> survplot from the rms package.
> 
> I am plotting the following:
> 
> survplot(survest(fita), n.risk=T, conf='none', cex.n.risk=.85, dots=T,
> col='gray10', lty=2)
> survplot(survest(fit), n.risk=F, conf='none', add=T)
> survplot(survest(fitb), n.risk=F, conf='none', col='gray20', add=T,
> lty=4)
> 
> I have tried to place 'label.curves=list(method="arrow", cex=.8)' and
> others as suggested in ?survplot in any and all of the above commands,
> but I do not get a legend regardless of whether I try to plot only one
> or several lines as above. Any suggestions as to how I can generate a
> legend would be greatly appreciated.
> 
> Thanks, Aric

Please send exact code for an example that fails.  If possible, generate 
the data using a simple simulation to make the example reproducible.

Frank

> 
> 
> sessionInfo()
> R version 2.9.2 (2009-08-24)
> i386-pc-solaris2.11
> 
> locale:
> C
> 
> attached base packages:
>  [1] splines   grid      tools     stats     graphics  grDevices
> utils [8] datasets  methods   base
> 
> other attached packages:
>  [1] rms_2.0-2          rankhazard_0.8     latticist_0.9-42
> vcd_1.2-4 [5] colorspace_1.0-1   MASS_7.2-48        latticeExtra_0.6-1
> RColorBrewer_1.0-2 [9] lattice_0.17-25    Hmisc_3.7-0
> survival_2.35-4    ggplot2_0.8.3 [13] reshape_0.8.3
> plyr_0.1.9         proto_0.3-8        fortunes_1.3-6
> 
> loaded via a namespace (and not attached):
> [1] cluster_1.12.0  gWidgets_0.0-37 tcltk_2.9.2
> 
> IMPORTANT WARNING:  This email (and any attachments) is ...{{dropped:9}}
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list