File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -336,21 +336,33 @@ check_outcome <- function(y, spec) {
336336 if (spec $ mode == " regression" ) {
337337 outcome_is_numeric <- if (is.atomic(y )) {is.numeric(y )} else {all(map_lgl(y , is.numeric ))}
338338 if (! outcome_is_numeric ) {
339- rlang :: abort(" For a regression model, the outcome should be numeric." )
339+ cls <- class(y )[[1 ]]
340+ abort(paste0(
341+ " For a regression model, the outcome should be `numeric`, " ,
342+ " not a `" , cls , " `."
343+ ))
340344 }
341345 }
342346
343347 if (spec $ mode == " classification" ) {
344348 outcome_is_factor <- if (is.atomic(y )) {is.factor(y )} else {all(map_lgl(y , is.factor ))}
345349 if (! outcome_is_factor ) {
346- rlang :: abort(" For a classification model, the outcome should be a factor." )
350+ cls <- class(y )[[1 ]]
351+ abort(paste0(
352+ " For a classification model, the outcome should be a `factor`, " ,
353+ " not a `" , cls , " `."
354+ ))
347355 }
348356 }
349357
350358 if (spec $ mode == " censored regression" ) {
351359 outcome_is_surv <- inherits(y , " Surv" )
352360 if (! outcome_is_surv ) {
353- rlang :: abort(" For a censored regression model, the outcome should be a `Surv` object." )
361+ cls <- class(y )[[1 ]]
362+ abort(paste0(
363+ " For a censored regression model, the outcome should be a `Surv` object, " ,
364+ " not a `" , cls , " `."
365+ ))
354366 }
355367 }
356368
You can’t perform that action at this time.
0 commit comments