Skip to content

Commit

Permalink
Merge pull request #1035 from tidymodels/spark-intercept
Browse files Browse the repository at this point in the history
Don't modify spark data in `form_form()`
  • Loading branch information
hfrick authored Dec 11, 2023
2 parents 0372970 + 2b85412 commit 0acbf8d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions R/fit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
form_form <-
function(object, control, env, ...) {

encoding_info <-
get_encoding(class(object)[1]) %>%
dplyr::filter(mode == object$mode, engine == object$engine)

remove_intercept <- encoding_info %>% dplyr::pull(remove_intercept)
if (remove_intercept) {
env$data <- env$data[, colnames(env$data) != "(Intercept)", drop = FALSE]
}

if (inherits(env$data, "data.frame")) {
check_outcome(eval_tidy(rlang::f_lhs(env$formula), env$data), object)

encoding_info <-
get_encoding(class(object)[1]) %>%
dplyr::filter(mode == object$mode, engine == object$engine)

remove_intercept <- encoding_info %>% dplyr::pull(remove_intercept)
if (remove_intercept) {
env$data <- env$data[, colnames(env$data) != "(Intercept)", drop = FALSE]
}
}

# prob rewrite this as simple subset/levels
Expand Down

0 comments on commit 0acbf8d

Please sign in to comment.