I was getting some errors with lmtp_{sdr, tmle, sub} when the input data is a tbl_df/tbl:
Error in `[[<-`(`*tmp*`, trt_var, value = NULL) :
Can't assign column with `trt_var`.
✖ Subscript `trt_var` must be a location, not a character `NA`.
Not sure if what I have suggested is the best fix for this, but it's one that worked for me. You could also assert the type of the input data is data.frame.
Example to replicate the error:
library(lmtp)
library(tibble)
A <- "trt"
Y <- paste0("Y.", 1:6)
C <- paste0("C.", 0:5)
W <- c("W1", "W2")
lmtp_{sdr, tmle, sub}(sim_point_surv |> tibble(), A, Y, W, cens = C, folds = 2,
shift = static_binary_on, outcome_type = "survival")
To illustrate root of error:
rdf <- data.frame()
rdf[[as.character(NA)]] <- NULL # This is fine; it will do nothing
tdf <- tibble()
tdf[[as.character(NA)]] <- NULL # This will error as lmtp does
Hi Nick,
I was getting some errors with
lmtp_{sdr, tmle, sub}
when the input data is atbl_df
/tbl
:Not sure if what I have suggested is the best fix for this, but it's one that worked for me. You could also assert the type of the input data is
data.frame
.Example to replicate the error:
To illustrate root of error: