Skip to content

use rlang::f_lhs() in favor of formula[[2]] #1013

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

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/fit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ form_form <-
function(object, control, env, ...) {

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

# prob rewrite this as simple subset/levels
Expand Down Expand Up @@ -53,7 +53,7 @@ form_form <-
)
elapsed <- list(elapsed = NA_real_)
}
res$preproc <- list(y_var = all.vars(env$formula[[2]]))
res$preproc <- list(y_var = all.vars(rlang::f_lhs(env$formula)))
res$elapsed <- elapsed
res
}
Expand Down Expand Up @@ -149,7 +149,7 @@ form_xy <- function(object, control, env,
control = control,
target = target
)
data_obj$y_var <- all.vars(env$formula[[2]])
data_obj$y_var <- all.vars(rlang::f_lhs(env$formula))
data_obj$x <- NULL
data_obj$y <- NULL
data_obj$weights <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/grouped_binomial.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ glm_grouped <- function(formula, data, weights, ...) {
data <- data[, all_cols, drop = FALSE]
data$..weights <- weights
# Reconstruct the new data format (made below) to the grouped formula format
formula[[2]] <- rlang::call2("cbind", !!!rlang::syms(rev(lvls)))
rlang::f_lhs(formula) <- rlang::call2("cbind", !!!rlang::syms(rev(lvls)))

data <-
data %>%
Expand Down
2 changes: 1 addition & 1 deletion R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ levels_from_formula <- function(f, dat) {
if (inherits(dat, "tbl_spark")) {
res <- NULL
} else {
res <- levels(eval_tidy(f[[2]], dat))
res <- levels(eval_tidy(rlang::f_lhs(f), dat))
}
res
}
Expand Down