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

Christos Hatzis christos at nuverabio.com
Sun Apr 29 05:28:01 CEST 2007

The Surv object contains the information on the type of censoring.  
Look at ?Surv
for an explanation of how censored events are represented.


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Lu, Jiang
> Sent: Saturday, April 28, 2007 11:10 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] how to code the censor variable for "survfit"
> 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
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list