Closed EmilHvitfeldt closed 11 months ago
This has effectively been done in https://github.com/tidymodels/recipes/pull/1156
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.
I talked to @topepo about this, and I'm going to put it into writing. I'm proposing a code refactor related to how
bake()
ing code is done. Most bake steps follow exact same patterns and it would be nice to have it cleaned up.I'll show by example, so let us look at
bake.step_bin2factor
https://github.com/tidymodels/recipes/blob/788d409b96587a3377b5846df93774dfce511726/R/bin2factor.R#L106-L117
This could be rewritten to:
At first glance, it is more code. However the code inside
bake.step_bin2factor()
will be identical to other 1-in-1-out steps. Just change the name of the*_impl()
function and pass in different arguments as needed. This change also allows for easier unit testing of the implementation of each step, separate from the {recipes} framework. I contemplated whether the*_impl()
function should take a list of arguments or just passing inobject
. But I see it as a cleaner refactor to pass in individual arguments, as it will make the tests easier to manage.This pattern will not work for all steps, as some steps add or delete columns. But similar patterns should be created for those scenarios.
List of steps that would need to be converted to follow this refactor (first pass)