[R] Unable to get Legend with survplot rms package

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


Aric Gregson wrote:
> On Mon, 26 Oct 2009 13:21:23 -0700
> Frank E Harrell Jr <f.harrell at vanderbilt.edu> wrote:
> 
>> Please send exact code for an example that fails.  If possible,
>> generate the data using a simple simulation to make the example
>> reproducible.
> 
> endtime <- c(251,753,753,791,732,1081,184,713,674,732,254,
> 644,782,753,278,184,715,832,531,604,231,825,857,376,679,231,552,
> 184,214,732)
> 
> outcome <- c(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
> FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,
> TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE)
> 
> srv.example <- Surv(endtime, outcome)
> 
> srv.example [Day] [1]  251   753
> +  753+  791+  732+ 1081+  184+  713+  674+  732+  254 644+ [13]  782+
> 753+  278+  184+  715+  832+  531   604+  231   825+ 857+  376+ [25]
> 679+  231   552+  184   214   732+
> 
> variable1 <-c(7.76,56.84,20.67,39.02,50.00,70.00,39.70,
> 29.12,17.31,36.00,9.76,7.14,4.00,51.56,15.81,53.57,15.12,45.95,
> 11.11,13.42,9.20,8.89,20.24,51.35,68.18,25.93,8.61,10.99,NA,5.41)
> 
> variable2 <-c(14.01,8.96,19.37,2.23,5.26,4.16,8.11,3.54,0.66,5.27,
> 4.99,4.15,15.63,10.31,8.08,5.08,3.08,1.41,9.73,8.24,4.71,9.49,2.81,
> 11.28,6.36,4.45,1.26,2.82,1.46,16.37)
> 
> variable3 <-c
> (1,2,1,0,0,1,NA,NA,NA,NA,0,NA,0,0,1,0,1,0,0,NA,0,0,0,0,NA,0,NA,0,3,0)
> 
> fit.example1 <- cph(srv.example ~ variable1, surv=T, x=T, y=T)
> 
> fit.example2 <- cph(srv.example ~ variable2, surv=T, x=T, y=T)
> 
> fit.example3 <- cph(srv.example ~ variable3, surv=T, x=T, y=T)
> 
> survplot(survest(fit.example1), n.risk=T, conf='none', cex.n.risk=.85,
> dots=T, col='gray10', lty=2)

The argument to survplot should be a cph or psm or survfit object (or a 
survest result on a psm object).

Frank

> 
> survplot(survest(fit.example2), n.risk=FALSE,conf='none', add=T)
> 
> survplot(survest(fit.example3), n.risk=FALSE, conf='none', add=T,
> col='gray20', lty=4)
> 
> thanks, Aric
> 
> IMPORTANT WARNING:  This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential.  You, the recipient, are obligated to maintain it in a safe, secure and confidential manner.  Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.
> 


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




More information about the R-help mailing list