[R] Sorting Surv objects

Therneau, Terry M., Ph.D. therneau at mayo.edu
Fri Feb 13 14:53:35 CET 2015


Your work around is not as "easy" looking to me.

Survival times come in multiple flavors: left censored, right censored, interval censored, 
left-truncated and right censored, and multi-state.  Can you give me guidance on how each 
of these should sort?  If a sort method is added to the package it needs to deal with all 
of these.

  Professor Ripley has pointed out that the default action of sort() for right censored 
times, which I agree is reasonable.

Terry Therneau (author of the survival package)


On 02/13/2015 05:00 AM, r-help-request at r-project.org wrote:
> It seems that Surv objects do not sort correctly.   This seems to be a bug.  Anyone else found this?
>
>> >survival.data
> [1] 4+ 3  1+ 2  5+
>> >class(survival.data)
> [1] "Surv"
>> >sort(survival.data)
> [1] 2  1+ 4+ 3  5+
>
> An easy work-around is to define a function sort.Surv



More information about the R-help mailing list