sahirbhatnagar/casebase

popTime fails when given a data.table

Closed this issue · 4 comments

I don't know why casebase::popTime fails when given a data.table, but it might be related to FAQ 1.1. Something changed Nov 2016. It's something happening in casebase:::checkArgsEventIndicator

library(casebase)
#> See example usage at http://sahirbhatnagar.com/casebase/
popTimeData <- popTime(data = bmtcrr, time = "ftime", event = "Status")

bt <- data.table::as.data.table(bmtcrr)
popTimeData <- popTime(data = bt, time = "ftime", event = "Status")
#> Error in `[.data.table`(data, , event): j (the 2nd argument inside [...]) is a single symbol but column name 'event' is not found. Perhaps you intended DT[, ..event]. This difference to data.frame is deliberate and explained in FAQ 1.1.

Created on 2020-02-26 by the reprex package (v0.3.0)

The problem I think is in data[,event] in casebase:::checkArgsEventIndicator. This should be changed to data[[event]]

I'll make the change in my next PR

We had similar issues earlier on with the other functions; see issue #5

If you look at the code, you can still see a few places where I left the old code commented out; see for example these lines.

If/when you fix these lines, make sure to add some tests!

This was closed by PR #80