In step_dummy_hash, the keep_original_cols=TRUE parameter is not working when collapse=TRUE
library(modeldata)
library(recipes)
library(textrecipes)
data("tate_text", package = "modeldata")
With collapse=FALSE original columns: artist, title, medium are still present after step_dummy_hash() since keep_original_cols=TRUE
recipes::recipe(tate_text, ~., strings_as_factors = FALSE) |>
textrecipes::step_dummy_hash(artist, title, medium, signed = TRUE, collapse = FALSE, keep_original_cols = TRUE) |>
recipes::prep() |>
recipes::bake(new_data = NULL) |>
colnames()
With collapse=TRUE original columns: artist, title, medium are no longer present after step_dummy_hash() despite
keep_original_cols=TRUE. This is not what should happen.
recipes::recipe(tate_text, ~., strings_as_factors = FALSE) |>
textrecipes::step_dummy_hash(artist, title, medium, signed = TRUE, collapse = TRUE, keep_original_cols = TRUE) |>
recipes::prep() |>
recipes::bake(new_data = NULL) |>
colnames()
The creation of "collapse" column "artist_title_medium" is an undocumented side-effects of collapse=TRUE. Curiously, this is the column that is dropped when keep_original_cols = FALSE (along with artist, title, medium)
In
step_dummy_hash, thekeep_original_cols=TRUEparameter is not working whencollapse=TRUEWith
collapse=FALSEoriginal columns: artist, title, medium are still present afterstep_dummy_hash()sincekeep_original_cols=TRUEWith
collapse=TRUEoriginal columns: artist, title, medium are no longer present afterstep_dummy_hash()despitekeep_original_cols=TRUE. This is not what should happen.The creation of "collapse" column "artist_title_medium" is an undocumented side-effects of
collapse=TRUE. Curiously, this is the column that is dropped whenkeep_original_cols = FALSE(along with artist, title, medium)