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

From: Osman Al-Radi <osman.al.radi_at_gmail.com>
Date: Wed 31 May 2006 - 08:19:45 EST

Prof. Harrell,

Thank you for your response. Potting the n.risk on the curve is probably only useful for a small data sets with a few censored events. The default present method is more general and has more applications. For my purpose I figured out a way of editing the postscript file in WinEdt.

Regards,

Osman

On 5/30/06, Frank E Harrell Jr <f.harrell@vanderbilt.edu> wrote:
>
> 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
>

-- 
Osman O. Al-Radi, MD, MSc, FRCSC
Fellow, Cardiovascular Surgery
The Hospital for Sick Children
University of Toronto, Canada

	[[alternative HTML version deleted]]

______________________________________________
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 08:34:53 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 - 13:22:59 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.