Re: [R] position of number at risk in survplot() graphs

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Wed 31 May 2006 - 06:04:47 EST

Osman Al-Radi wrote:
> Dear R-help
>
> How can one get survplot() to place the number at risk just below the
> survival curve as opposed to the default which is just above the x-axis?
> I tried the code bellow but the result is not satisfactory as some numbers
> are repeated several times at different y coordinates and the position of
> the n.risk numbers corresponds to the x-axis tick marks not the survival
> curve time of censoring.
>
> n <- 20
> set.seed(731)
> cens <- 15*runif(n)
> h <- .02*exp(2)
> dt <- -log(runif(n))/h
> label(dt) <- 'Follow-up Time'
> e <- ifelse(dt <= cens,1,0)
> dt <- pmin(dt, cens)
> units(dt) <- "Year"
> S <- Surv(dt,e)
> km<-survfit(S~1)
> survplot(km,n.risk=T,conf='none', y.n.risk=unique(summary(km)$surv))
>
> Any suggestion on addressing this problem would be apprecited.
>
> Also, is there a way to add a tick mark to the survival curve at times of
> censoring similar to the mark.time=T argument in plot.survplot()?
>
> Thanks
>
> Osman
>

Osman,

y.n.risk has to be a scalar and gives the y-coordinate of the bottom line of number at risk. I take it that you want the numbers not all at the same height. This will require a customization of survplot or fetching information from the km object and using text( ).

Frank

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

______________________________________________
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 Wed May 31 07:12:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 31 May 2006 - 10:12:31 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.