How to figure out which column names are illegal in ranger?

1.1k views Asked by At

Here is a ranger call:

rf_fit <- 
  rf_mod %>% 
  fit(my_outcome_factor ~ ., data = data_train)

and the output:

Error in parse.formula(formula, data, env = parent.frame()) : 
  Error: Illegal column names in formula interface. Fix column names or use alternative interface in ranger.

How can I tell which columns are illegal?

I tried setting up a function foo() to debug:

foo <- function() {
  browser()
  ranger:::parse.formula(my_outcome_factor ~ ., data = data_train)
}

This function didn't help me much, because I don't know how to get a breakpoint in the right spot.

It's ranger version 0.12.1.

1

There are 1 answers

0
DA Sukit Fasebok On

I have encountered this error when mistakenly trying to feed ranger column names that start with a numeric. Adding a character prefix solved it.