|
39 | 39 | #' the data are converted to the required format. In this case, any |
40 | 40 | #' calls in the resulting model objects reference the temporary |
41 | 41 | #' objects used to fit the model. |
| 42 | +#' |
| 43 | +#' If the model engine has not been set, the model's default engine will be used |
| 44 | +#' (as discussed on each model page). If the `verbosity` option of |
| 45 | +#' [fit_control()] is greater than zero, a warning will be produced. |
42 | 46 | #' @examples |
43 | 47 | #' # Although `glm()` only has a formula interface, different |
44 | 48 | #' # methods for specifying the model can be used |
@@ -93,8 +97,13 @@ fit.model_spec <- |
93 | 97 | ... |
94 | 98 | ) { |
95 | 99 | dots <- quos(...) |
96 | | - if (any(names(dots) == "engine")) |
97 | | - stop("Use `set_engine()` to supply the engine.", call. = FALSE) |
| 100 | + if (is.null(object$engine)) { |
| 101 | + eng_vals <- possible_engines(object) |
| 102 | + object$engine <- eng_vals[1] |
| 103 | + if (control$verbosity > 0) { |
| 104 | + warning("Engine set to `", object$engine, "`", call. = FALSE) |
| 105 | + } |
| 106 | + } |
98 | 107 |
|
99 | 108 | if (all(c("x", "y") %in% names(dots))) |
100 | 109 | stop("`fit.model_spec()` is for the formula methods. Use `fit_xy()` instead.", |
@@ -177,8 +186,13 @@ fit_xy.model_spec <- |
177 | 186 | ... |
178 | 187 | ) { |
179 | 188 | dots <- quos(...) |
180 | | - if (any(names(dots) == "engine")) |
181 | | - stop("Use `set_engine()` to supply the engine.", call. = FALSE) |
| 189 | + if (is.null(object$engine)) { |
| 190 | + eng_vals <- possible_engines(object) |
| 191 | + object$engine <- eng_vals[1] |
| 192 | + if (control$verbosity > 0) { |
| 193 | + warning("Engine set to `", object$engine, "`", call. = FALSE) |
| 194 | + } |
| 195 | + } |
182 | 196 |
|
183 | 197 | if (object$engine != "spark" & NCOL(y) == 1 & !(is.vector(y) | is.factor(y))) { |
184 | 198 | if (is.matrix(y)) { |
|
0 commit comments