Skip to content

Commit 6bb26b3

Browse files
authored
speed up ensure_parsnip_format() (#945)
1 parent 59e18dd commit 6bb26b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/predict.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ format_hazard <- function(x) {
302302

303303
ensure_parsnip_format <- function(x, col_name, overwrite = TRUE) {
304304
if (isTRUE(ncol(x) > 1) | is.data.frame(x)) {
305-
x <- as_tibble(x, .name_repair = "minimal")
305+
x <- tibble::new_tibble(x)
306306
if (!any(grepl(paste0("^\\", col_name), names(x)))) {
307307
if (overwrite) {
308308
names(x) <- col_name
@@ -311,7 +311,8 @@ ensure_parsnip_format <- function(x, col_name, overwrite = TRUE) {
311311
}
312312
}
313313
} else {
314-
x <- tibble(unname(x))
314+
x <- tibble::new_tibble(vctrs::df_list(unname(x), .name_repair = "minimal"),
315+
nrow = length(x))
315316
names(x) <- col_name
316317
x
317318
}

0 commit comments

Comments
 (0)