[R] Unable to get Legend with survplot rms package

Aric Gregson agregson at mednet.ucla.edu
Mon Oct 26 21:52:12 CET 2009


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)

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 ...{{dropped:9}}




More information about the R-help mailing list