Skip to content

factor_to_indicators errors with unhelpful message if a factor has only one level #285

Open

Description

@benkeser
grbg <- data.table(y = 1:10, x = as.factor(rep("F", 10)), z = 1:10)

grbg_task <- sl3_Task$new(data = grbg,
                          covariates = c("x", "z"),
                          outcome = "y")

grbg_task$X

Obviously this is sort of a user error, but the error message is

Error in ind_ref_mat[as.numeric(x), , drop = FALSE] : 
  incorrect number of dimensions

which is not helpful. And I could see users processing data without fully checking that all levels of a factor are present (that's what I did 😳).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions