[R] how to code the censor variable for "survfit"

Lu, Jiang lu.jjane at gmail.com
Sun Apr 29 05:10:00 CEST 2007


Dear r-helpers,

This is my first time to run survival analysis. Currently, I have a
data set which contains two variables, the variable of time to event
(or time to censoring) and the variable of censor indicator. For the
indicator variable, it was coded as 0 and 1. 0 represents right
censor, 1 means event of interest. Now I try to use "survfit" in the
package of "survival". I wrote the following code:
> rptsurv <- survfit(surv(time,censor)~1,data=x)

Before I run the code, I am concerned with my 0/1 coding to the censor
indicator because I did not see any argument in the syntax of
"survfit", which may tell the program that value 1 means event. I
checked the documentations and R-help archive, but ended in vain.

Would you please kindly tell me how "survfit" treats censor variables?
In 0/1 coding, is it the default that 1 means event and 0 means right
censor? What if the censor was coded as 2 or 3 instead of 0 or 1? I
means how the "survfit" knows the difference. In SAS, if a "lifetest"
procedure (similar to survfit) is performed, there is an argument
specifying which value in the censor variable is treated as event.

I know I could just compare the results from R and from SAS to see the
difference. However, I really want to know exactly how "survfit" deals
with this problem. Thank you very much in advance.

sincerely,

Jiang Lu
University of Pittsburgh



More information about the R-help mailing list