Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error with assigning null to under shift dataframes #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakewilliami
Copy link

Hi Nick,

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

@nt-williams
Copy link
Owner

Hey @jakewilliami , thanks for bringing this up! Could you open up an issue?

@jakewilliami
Copy link
Author

#137 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants