Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upQ: Data first in the pipeline? #46
Comments
|
The formula comes first so that that it is an S3 |
|
OK, sounds good! :) |
|
Some thinking quasi out loud about this... If we were to do this, we would get rid of the formula method for the The current class system has: recipe <- function(x, ...) UseMethod("recipe")
## `...`` are not currently hooked up to anything
recipe.default <- function(x, vars = colnames(x), roles = NULL, ...) {
# code
}
recipe.formula <- function(formula, data, ...) {
# code that eventually calls `recipe.default`
}If the function is called in the usual way with a formula: recipe(y ~ x, data = biomass_tr)but there is no formula method, this ends up being # case 1
recipe.default(x = y ~ x, data = biomass_tr)Note that If called from a pipe: data %>% recipe(y ~ x)the default method would result in # case 2
recipe.default(x = biomass_tr, vars = y ~ x)In both cases, we would need to pass to some other non-method function (say It seems pretty ugly since, in case 1, Is there a more elegant way to get to the same place? |
|
Why not something like this: recipe <- function(data, formula = NULL, ...) UseMethod("recipe")
recipe.data.frame <- function(x, formula = NULL, ..., vars = colnames(x), roles = NULL) {
recipe <- ...
if (!is.null(formula))
recipe <- step_formula(recipe, formula)
}Then |
|
That should solve it but please test with your problem |
Hi there!
Thanks so much for your work so far on this, I'm really looking forward to seeing this package develop!
I was wondering if you have any thoughts on placing data as the first argument in a recipe?
This would then mean that the README code could then be:
This idea has been made possible with the intubate package, but perhaps this could be something provided in recipes?
Thank you again for all your work!