invalid formula in r
09:52 03 Dec 2025

I am building a recipe to search for interaction terms of the ames dataset, the problem that I encounter is this,

if I set the interaction term as interac_term <- ~starts_with("Buld_Type"):starts_with("Neighborhood")

and define the recipe like this

int_rec <- ames_rec %>%
    step_interact(interac_term) %>% 
    step_zv(all_predictors())

I get this error:

Error in formula.character(object, env = baseenv()) : 
  invalid formula "interac_term": not a call

but, if I define the recipe like this

int_rec <- ames_rec %>%
    step_interact(~starts_with("Bldg_Type"):starts_with("Neighborhood")) %>% 
    step_zv(all_predictors())

the recipe works fine, no error

what could be the problem here?

r