therneau / survival

Survival package for R
394 stars 106 forks source link

Prevent negative indexing in tmerge(). #280

Open lukaszdaniel opened 2 months ago

lukaszdaniel commented 2 months ago

Fixing a bug where 'nid2' integer vector was accessed with k=-1. By pure luck nid[-1] currently gives 0, instead of garbage value. (I'm recreating the pull request, beacuse I polluted the previous one).

Additional info: k=-1 case is triggered for example in multi2.R test when evaluating tdata

tdata <- tmerge(myeloid[,1:3], myeloid, id=id, death=event(futime,death),
                priortx = tdc(txtime), sct= event(txtime))

After applying if (k > 0) fix all survival tests passed successfully.