-
Notifications
You must be signed in to change notification settings - Fork 92
document that main arguments are captured as quosures #918
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
Conversation
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.
Hm, I think we should change something about that model_type()
snippet. It using the actual modelling function would be nice. A possibly easier solution is to explicitly say that this is pseudo-code. Either solution is fine with me.
man-roxygen/spec-details.R
Outdated
@@ -6,3 +6,12 @@ | |||
#' | |||
#' The model is not trained or fit until the [`fit()`][fit.model_spec()] function is used | |||
#' with the data. | |||
#' | |||
#' Each of the arguments defaulting to `NULL` in this function are captured |
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 think the pattern is "every arg apart from mode
and engine
" but I haven't checked all of them. I did hit bag_tree()
though which has non-NULL defaults for some main args and all of them get captured as quosures:
Lines 25 to 37 in 332de18
bag_tree <- | |
function(mode = "unknown", | |
cost_complexity = 0, | |
tree_depth = NULL, | |
min_n = 2, | |
class_cost = NULL, | |
engine = "rpart") { | |
args <- list( | |
cost_complexity = enquo(cost_complexity), | |
tree_depth = enquo(tree_depth), | |
min_n = enquo(min_n), | |
class_cost = enquo(class_cost) | |
) |
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.
Ah, good point. Thank you!
I'm with ya. Let's make this into a proper template and substitute the function name in. |
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.
That's so neat! I didn't know about that 👀 🤩
This pull request 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. |
Closes #662.🦀
If we think the
model_type()
pseudocode may be confusing for folks, we could make this into a proper template that could take the name of the model type function as an input. :)