-
Notifications
You must be signed in to change notification settings - Fork 123
add ignore_step function #1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ignore_step function #1324
Conversation
hfrick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not use "ignore" in the name here because that implies the step(s) in question are still part of the recipe, they just don't get used -- but this does remove them. I think remove_step() would be the cleanest but if we want to avoid "remove" because of step_rm(), we could go with "undo" or "delete".
| if (n_steps == 0) { | ||
| cli::cli_abort("{.arg x} doesn't contain any steps to remove.") | ||
| } | ||
|
|
||
| arg <- rlang::check_exclusive(number, id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could allow ignore_step(<recipes without steps>) and just have it do nothing. If we don't want that, I would swap these two checks. To me, it's more obvious then that we don't allow that because we always require you to provide what to remove (before we tell you that there is nothing to remove).
| #' | ||
| #' ignore_step(rec, id = "PCA") | ||
| #' @export | ||
| ignore_step <- function(x, number, id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would give number and id some default values since only one of the two is required. tidy() uses NA.
| expect_equal( | ||
| ignore_attr = TRUE, | ||
| ignore_step(rec1234, number = 1), | ||
| rec234 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised by the argument order here, why do you put ignore_attr up front?
| #' `ignore_step` will return a recipe without steps specified by the `number` or | ||
| #' `id` argument. | ||
| #' | ||
| #' @param x A `recipe` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #' @param x A `recipe` object. | |
| #' @param x An untrained `recipe` object. |
| #' @param number An integer vector, Denoting the positions of the steps that | ||
| #' should be removed. | ||
| #' @param id A character string. Denoting the `id` of the steps that should be | ||
| #' removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #' @param number An integer vector, Denoting the positions of the steps that | |
| #' should be removed. | |
| #' @param id A character string. Denoting the `id` of the steps that should be | |
| #' removed. | |
| #' @param number An integer vector denoting the positions of the steps that | |
| #' should be removed. | |
| #' @param id A character string denoting the `id` of the steps that should be | |
| #' removed. |
|
We are sitting on this for another week. Brief summary of meeting discussion:
|
|
we are sitting on this at least another week |
|
Hello, I stumbled onto this feature when trying to figure out a way to modify my tidymodels recipe in my Shiny app. For context, I am building a Shiny app to allow end users to interactively fit and analyse GLM models. As part of this, I am storing my As a workaround, I have currently copied over the ignore_step.R file to my project to be able to use this functionality. I have also modified it slightly to allow the passing a recipe step name as a character string. For example, the below will delete the For reference, here's a link to the modified ignore_step.R file that I am using: ignore_step.R However, reading through the previous comments I can see that there are still a few open design considerations. Given that here hasn't been any further traction on this ticket, I am guessing there are no plans to include this in a future release? The current workaround does the job for me but having it as part of the core recipes package (or an extension package) would definitely be ideal! Thanks again for the original code! It really helped me solve my problem 😄. P.S. I am also not a huge fan of the |
|
Hello @sen-kaustav 👋 I'm happy to hear that you found the function useful, and you are of course welcome to have copied the function over to your project. After having been thinking it over, I don't think that this function should belong in {recipes} itself. It is definitely useful but we don't think it fits the scope of this package. |
to close #887
Adds
ignore_step(), with a similar interface astidy()with respect to how we select, either usingnumberorid.I'm not in love with the name, so suggestions are welcome.