[R] Sorting Surv objects
Professor Bickis
bickis at snoopy.usask.ca
Thu Feb 12 17:26:26 CET 2015
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
sort.Surv<-function(a){ord<-order(a[,1])
+ a[ord]}
> sort(survival.data)
[1] 1+ 2 3 4+ 5+
I am using R 3.1.2 GUI 1.65 Mavericks build (6833) running under Yosemite.
More information about the R-help
mailing list