Skip to content

Commit 1afcd2f

Browse files
authored
use rlang::f_lhs() in favor of formula[[2]] (#1013)
1 parent 907d216 commit 1afcd2f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

R/fit_helpers.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ form_form <-
77
function(object, control, env, ...) {
88

99
if (inherits(env$data, "data.frame")) {
10-
check_outcome(eval_tidy(env$formula[[2]], env$data), object)
10+
check_outcome(eval_tidy(rlang::f_lhs(env$formula), env$data), object)
1111
}
1212

1313
# prob rewrite this as simple subset/levels
@@ -53,7 +53,7 @@ form_form <-
5353
)
5454
elapsed <- list(elapsed = NA_real_)
5555
}
56-
res$preproc <- list(y_var = all.vars(env$formula[[2]]))
56+
res$preproc <- list(y_var = all.vars(rlang::f_lhs(env$formula)))
5757
res$elapsed <- elapsed
5858
res
5959
}
@@ -149,7 +149,7 @@ form_xy <- function(object, control, env,
149149
control = control,
150150
target = target
151151
)
152-
data_obj$y_var <- all.vars(env$formula[[2]])
152+
data_obj$y_var <- all.vars(rlang::f_lhs(env$formula))
153153
data_obj$x <- NULL
154154
data_obj$y <- NULL
155155
data_obj$weights <- NULL

R/grouped_binomial.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ glm_grouped <- function(formula, data, weights, ...) {
103103
data <- data[, all_cols, drop = FALSE]
104104
data$..weights <- weights
105105
# Reconstruct the new data format (made below) to the grouped formula format
106-
formula[[2]] <- rlang::call2("cbind", !!!rlang::syms(rev(lvls)))
106+
rlang::f_lhs(formula) <- rlang::call2("cbind", !!!rlang::syms(rev(lvls)))
107107

108108
data <-
109109
data %>%

R/misc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ levels_from_formula <- function(f, dat) {
260260
if (inherits(dat, "tbl_spark")) {
261261
res <- NULL
262262
} else {
263-
res <- levels(eval_tidy(f[[2]], dat))
263+
res <- levels(eval_tidy(rlang::f_lhs(f), dat))
264264
}
265265
res
266266
}

0 commit comments

Comments
 (0)