tidymodels / tidymodels.org

Source of tidymodels.org
https://www.tidymodels.org/
19 stars 15 forks source link

A possible error in "Create your own recipe step function"? #34

Closed zhuxr11 closed 1 year ago

zhuxr11 commented 1 year ago

From website: In step_percentile(), terms = terms is passed on to step_percentile_new(). This will set terms member of the step to function stats::terms. However, in prep.step_percentile(), x$terms is used in recipes_eval_select() as the first argument, which is expected to be a quosure list to select variables to apply the step. Since x$term = stats::terms is a function, this will throw an error:

Error in enexpr(expr) : 
  Can't splice an object of type `closure` because it is not a vector

I changed the function call to step_percentile_new() to follows (note the change terms = rlang::enquos(...), and it worked as expected:

step_percentile_new(
      terms = rlang::enquos(...), 
      trained = trained,
      role = role, 
      ref_dist = ref_dist,
      options = options,
      skip = skip,
      id = id
)
EmilHvitfeldt commented 1 year ago

Hello @zhuxr11 👋

Thank you for reporting, I have implemented the change and a few more in https://github.com/tidymodels/tidymodels.org/pull/35. It should b live shortly