Skip to content

Commit d1d4df4

Browse files
committed
only turn into sparse data frame if model allow sparse data
1 parent 4584a9b commit d1d4df4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

R/fit.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,16 @@ fit_xy.model_spec <-
275275
}
276276
}
277277

278-
if (allow_sparse(object) && methods::is(x, "sparseMatrix")) {
279-
x <- sparsevctrs::coerce_to_sparse_data_frame(x)
278+
if (methods::is(x, "sparseMatrix")) {
279+
if (allow_sparse(object)) {
280+
x <- sparsevctrs::coerce_to_sparse_data_frame(x)
281+
} else {
282+
cli::cli_warn(c(
283+
"!" = "{.arg x} is a sparse matrix, but model doesn't accept that.",
284+
"i" = "Converted {.arg x} to data.frame."
285+
))
286+
x <- as.data.frame(x)
287+
}
280288
}
281289

282290
cl <- match.call(expand.dots = TRUE)

0 commit comments

Comments
 (0)