[R] Survival Statistics

Gregory Pierce pierce.gregory at gmail.com
Tue Jun 6 02:02:57 CEST 2006

Hello friends and fellow R users,

I have a problem to which I have been unable to find a solution: I am
gathering survival data on patients undergoing treatment with a new kind
of stent. I want to generate survival data and plot survival curves of
these patients based (among other things) on the treating physician. My
data set has been tabulated in the following manner:

Date    (the date the stent was implanted)   
Description (diameter of the stent)
Patient (name)
MRN (ID number)
Age (age in years of the patient)
Physician (last name of the implanting physician)
status (0 or 1)
days (days alive since the stenting procedure)

The data set has over ten physicians. Following the examples in
"Introductory Statistics with R" I have been able to draw cumulative
survival curves and even the survival curves by physician but there are
so many curves on the graph when I do, it is uninterpretable.

I would just like to plot the survival curves of say the top two or
three. That would be much more useful. I have been able to create a
"Surv" object out of my own survival data and that of a colleague in the
following way using indexing:

[1] 558+ 474+ 472+ 446+ 443+ 429+ 401  395+ 390  390+ 362+ 354  344+ 342
[16] 300+ 284+ 280+ 246+ 237+ 233+ 233  230+ 230+ 225+ 215  199+ 191+
191  184+
[31] 161+ 153  150  129+  69+  52+  38+

I can get even further:

> survfit(surv.ee.gp)
Call: survfit(formula = surv.ee.gp)

      n  events  median 0.95LCL 0.95UCL
     37       9     Inf     390     Inf

But now if I want to plot the data using the following command


I receive an error:

Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  :
        invalid variable type

I have tried indexing Physician, but that fails as well:

> plot(survfit(surv.ee.gp)~Physician[viatorr[6]=="Pierce"|
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  :
        invalid variable type

I apologize for this long-winded explanation but I am new to this
program and even newer to Statistics and I wanted to make sure the
context and problem were clear (hopefully).

I would appreciate any guidance in a way forward. 

Thank you,

More information about the R-help mailing list