Closed prockenschaub closed 1 year ago
Thanks for raising this. You're right, the results are off and your fix gives us correct results. It happens due to id_tbl
and data.table
having slightly different semantics (default arguments that is) for unique()
. If the argument passed to foverlaps()
as y
inherits from ts_tbl
, an id_tbl
object will result as uy
here, as the index_var
is lost along the way. Uniqueness for id_tbl
by default is determined by the id_var
column whereas for data.table
is is for all columns, which in this case includes the pos
column.
I will fix this specific issue accordingly.
Problem
vaso60
usesmerge_ranges
to look for overlaps in vasopressor times of the same ICU stay, which in turn usesdata.table
'sfoverlaps
. The relevant line of code is here:https://github.com/eth-mds/ricu/blob/9e76c074250046da93870063c3b7ed57d274b790/R/utils-ts.R#L577
I noticed that the output for
dobu60
on the mimic demo data wasn't quite was I was expecting.Not how in line 6 the ranges aren't actually overlapping. Instead,
charttime
anddobu_dur
in lines 6 and 7 should read 582 mins and 1548 mins. This appears to be a weird interaction due to thets_tbl
class. If I downcast it to a vanilladata.table
, everything works as expected.Problem
Change to
reclass_tbl(data.table::foverlaps(as.data.table(x), as.data.table(x), mult = "first"), as_ptype(x))
or identify the underlying root cause ints_tbl
.