title: Kaplan-Meier including survival and transplant data
body: <p>What I have is a Kaplan-Meier Analysis of patients with mechanical heart support using R.</p>
  
  <p>What I need is adding the following data into the plot (like in the example):</p>
  
  <ul>
  <li>patients who survived due to a heart transplantation (HTX)</li>
  <li>patients who died</li>
  </ul>
  
  <p>In other words, there are two groups where one is a subset (transplanted patients) of the other (all patients). These two curves must start at 0/0 and will increase.</p>
  
  <p>My own plot is done by:</p>
  
  <pre><code>pump &lt;- read.table(file=datafile, header=FALSE,
                     col.names=c('TIME', 'CENSUS', 'DEVICE'))
  # convert days to months
  pump$TIME &lt;- pump$TIME/(730/24)
  mfit.overall &lt;- survfit(Surv(TIME, CENSUS==0) ~ 1, data=pump)
  plot(mfit.overall, xlab="months on device", ylab="cum. survival", xaxt="n")
  axis(1, at=seq(from=0, to=24, by=6), las=0)
  </code></pre>
  
  <p>How may I add the two additional curves?</p>
  
  <p>Kind Regards
  Johann</p>
  
  <p>Sample Kaplan Meier Curve: <a href="http://ars.sciencedirect.com/content/image/1-s2.0-S1053249811007583-gr2.jpg" rel="nofollow">http://i.stack.imgur.com/158e8.jpg</a></p>
  
  <p>Demo Data:</p>
  
  <p>Survival Data, which goes into pump:</p>
  
  <blockquote>
  <pre><code>TIME    CENSUS  DEVICE
  426     1       1
  349     1       1
  558     1       1
  402     1       1
  12      0       1
  84      0       1
  308     1       1
  174     1       1
  315     1       1
  734     1       1
  544     1       2
  1433    1       2
  1422    1       2
  262     1       2
  318     1       2
  288     1       2
  1000    1       2
  </code></pre>
  </blockquote>
  
  <p>TX data:</p>
  
  <blockquote>
  <pre><code>TIME    CENSUS  DEVICE
  426     1        1
  288     1        2
  308     1        1
  </code></pre>
  </blockquote>
  
  <p>deaths:</p>
  
  <blockquote>
  <pre><code>TIME    CENSUS  DEVICE
  12      0        1
  84      0        1
  </code></pre>
  </blockquote>