-
Notifications
You must be signed in to change notification settings - Fork 105
Closed
Description
I gave a little thought to the fit() interface problem and this is what I came up with. I don't really like the interface arg name but thats just a naming thing.
# helper if required
xy <- function(x, y) {
list(x = x, y = y)
}
# notice how engine would come before the _optional_ data param for pipeability
# all required params are now moved to the front
# engine could come before interface if you want to keep interface+data together
fit <- function(model_spec, interface, engine, data, control, ...) {
#switch based on interface being a formula VS list
}
linear_reg() %>%
fit(y ~ x1 + x2, "lm", fit_data)
linear_reg() %>%
fit(xy(fit_data[,c("x1", "x2")], fit_data[,c("y")]), "lm")
# slightly simpler
xy_defn <- xy(
x = fit_data[,c("x1", "x2")],
y = fit_data[,c("y")]
)
linear_reg() %>%
fit(xy_defn, "lm")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels