Skip to content

Commit 0e37996

Browse files
committed
earlier exit for sparse matrix in fit()
1 parent 31506c7 commit 0e37996

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

R/fit.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ fit.model_spec <-
137137
cli::cli_abort(msg)
138138
}
139139

140+
if (is_sparse_matrix(data)) {
141+
outcome_names <- all.names(rlang::f_lhs(formula))
142+
outcome_ind <- match(outcome_names, colnames(data))
143+
144+
y <- data[, outcome_ind]
145+
x <- data[, -outcome_ind, drop = TRUE]
146+
147+
return(fit_xy(object, x, y, case_weights, control, ...))
148+
}
149+
140150
dots <- quos(...)
141151

142152
if (length(possible_engines(object)) == 0) {
@@ -174,16 +184,6 @@ fit.model_spec <-
174184
eval_env$formula <- formula
175185
eval_env$weights <- wts
176186

177-
if (is_sparse_matrix(data)) {
178-
outcome_names <- all.names(rlang::f_lhs(formula))
179-
outcome_ind <- match(outcome_names, colnames(data))
180-
181-
y <- data[, outcome_ind]
182-
x <- data[, -outcome_ind, drop = TRUE]
183-
184-
return(fit_xy(object, x, y, case_weights, control, ...))
185-
}
186-
187187
data <- materialize_sparse_tibble(data, object, "data")
188188

189189
fit_interface <-

0 commit comments

Comments
 (0)