diff --git a/R/nearest_neighbor_data.R b/R/nearest_neighbor_data.R index 7eaf36b40..a24051f61 100644 --- a/R/nearest_neighbor_data.R +++ b/R/nearest_neighbor_data.R @@ -93,9 +93,9 @@ set_pred( # model mode pre = function(x, object) { if (object$fit$response != "continuous") { - rlang::abort( - glue::glue("`kknn` model does not appear to use numeric predictions.", - " Was the model fit with a continuous response variable?") + cli::cli_abort( + c("`kknn` model does not appear to use numeric predictions.", + "i" = "Was the model fit with a continuous response variable?") ) } x @@ -136,9 +136,9 @@ set_pred( value = list( pre = function(x, object) { if (!(object$fit$response %in% c("ordinal", "nominal"))) { - rlang::abort( - glue::glue("`kknn` model does not appear to use class predictions.", - " Was the model fit with a factor response variable?") + cli::cli_abort( + c("`kknn` model does not appear to use class predictions.", + "i" = "Was the model fit with a factor response variable?") ) } x @@ -162,9 +162,9 @@ set_pred( value = list( pre = function(x, object) { if (!(object$fit$response %in% c("ordinal", "nominal"))) { - rlang::abort( - glue::glue("`kknn` model does not appear to use class predictions.", - " Was the model fit with a factor response variable?") + cli::cli_abort( + c("`kknn` model does not appear to use class predictions.", + "i" = "Was the model fit with a factor response variable?") ) } x diff --git a/R/rand_forest.R b/R/rand_forest.R index 2a6aed042..f15b5e906 100644 --- a/R/rand_forest.R +++ b/R/rand_forest.R @@ -99,9 +99,9 @@ translate.rand_forest <- function(x, engine = x$engine, ...) { if (x$engine == "spark") { if (x$mode == "unknown") { - rlang::abort( - glue::glue("For spark random forests models, the mode cannot ", - "be 'unknown' if the specification is to be translated.") + cli::cli_abort( + "For spark random forest models, the mode cannot + be {.val unknown} if the specification is to be translated." ) } else { arg_vals$type <- x$mode @@ -121,7 +121,12 @@ translate.rand_forest <- function(x, engine = x$engine, ...) { if (any(names(arg_vals) == "importance")) { if (isTRUE(is.logical(quo_get_expr(arg_vals$importance)))) { - rlang::abort("`importance` should be a character value. See ?ranger::ranger.") + cli::cli_abort( + c( + "{.arg importance} should be a character value.", + "i" = "See ?ranger::ranger." + ) + ) } } # unless otherwise specified, classification models are probability forests diff --git a/R/rand_forest_data.R b/R/rand_forest_data.R index 5ea5e6f1d..e73406e78 100644 --- a/R/rand_forest_data.R +++ b/R/rand_forest_data.R @@ -64,11 +64,9 @@ ranger_confint <- function(object, new_data, ...) { if (object$fit$forest$treetype == "Probability estimation") { res <- ranger_class_confint(object, new_data, ...) } else { - rlang::abort( - glue::glue( - "Cannot compute confidence intervals for a ranger forest ", - "of type {object$fit$forest$treetype}." - ) + cli::cli_abort( + "Cannot compute confidence intervals for a ranger forest + of type {.val {object$fit$forest$treetype}}." ) } } @@ -204,10 +202,10 @@ set_pred( value = list( pre = function(x, object) { if (object$fit$forest$treetype != "Probability estimation") - rlang::abort( - glue::glue( - "`ranger` model does not appear to use class probabilities. Was ", - "the model fit with `probability = TRUE`?" + cli::cli_abort( + c( + "`ranger` model does not appear to use class probabilities.", + "i" = "Was the model fit with `probability = TRUE`?" ) ) x diff --git a/R/svm_linear.R b/R/svm_linear.R index 2548cd499..29bac41a6 100644 --- a/R/svm_linear.R +++ b/R/svm_linear.R @@ -105,10 +105,9 @@ translate.svm_linear <- function(x, engine = x$engine, ...) { arg_vals$svr_eps <- 0.1 if (!is_null(liblinear_type)) if(!liblinear_type %in% 11:13) - rlang::abort( - paste0("The LiblineaR engine argument of `type` = ", - liblinear_type, - " does not correspond to an SVM regression model.") + cli::cli_abort( + "The LiblineaR engine argument {.code type = {liblinear_type}} + does not correspond to an SVM regression model." ) } else if (x$mode == "classification") { if (!is_null(liblinear_type)) diff --git a/R/svm_rbf_data.R b/R/svm_rbf_data.R index 84fad0cb4..5106ff4f1 100644 --- a/R/svm_rbf_data.R +++ b/R/svm_rbf_data.R @@ -296,9 +296,11 @@ set_pred( value = list( pre = function(x, object) { if (!object$fit$predict.prob) { - rlang::abort( - paste0("`svm` model does not appear to use class probabilities. Was ", - "the model fit with `predict.prob = TRUE`?") + cli::cli_abort( + c( + "The model does not appear to use class probabilities.", + "i" = "Was the model fit with {.code predict.prob = TRUE}?" + ) ) } x