0

Under the x-axis marks, I'd like to annotate the y-values corresponding to those x-values. Best explained by this graph: Example

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
Patrick
  • 11
  • 1
  • 1
    Please post a reproducible example of the code you have so far. Guidance on doing so is here http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Ari B. Friedman Aug 10 '11 at 15:53
  • 2
    There are more x axis points in that plot than there are summaries beneath it. Because there is no clear mapping of summary to x-axis values, it doesn't even appear to represent what you've requested. At a higher level, it looks like a bad way to present data. – Iterator Aug 10 '11 at 15:57

1 Answers1

2

If Frank Harrell were a contributor here I would wait for him to post but since he's not, here's a minor modification from the first example in help(survplot) in his great "rms" package:

require(rms)
n <- 1000
set.seed(731)
age <- 50 + 12*rnorm(n)
label(age) <- "Age"
sex <- factor(sample(c('male','female'), n, TRUE))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='female'))
dt <- -log(runif(n))/h
label(dt) <- 'Follow-up Time'
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
dd <- datadist(age, sex)
options(datadist='dd')
S <- Surv(dt,e)

# When age is in the model by itself and we predict at the mean age,
# approximate confidence intervals are ok

survplot(f, age=mean(age), conf.int=.95, 
               n.risk=TRUE, adj.n.risk=.75, y.n.risk=-0.15,
               xlab="")
title(main="Simulated Survival Plot Demonstrating Annotation of N-at-risk")
mtext("Follow-up Years", side=1, line=2)

enter image description here

IRTFM
  • 258,963
  • 21
  • 364
  • 487