diff --git a/NAMESPACE b/NAMESPACE index 84cd66a4e..84d39b78c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,8 +25,8 @@ S3method(as.data.frame,performance_score) S3method(as.data.frame,r2_bayes) S3method(as.data.frame,r2_loo) S3method(as.data.frame,r2_nakagawa) +S3method(as.double,check_outliers) S3method(as.double,performance_roc) -S3method(as.numeric,check_outliers) S3method(check_autocorrelation,default) S3method(check_collinearity,BFBayesFactor) S3method(check_collinearity,MixMod) diff --git a/R/check_outliers.R b/R/check_outliers.R index 0e68d1b18..8770e12b3 100644 --- a/R/check_outliers.R +++ b/R/check_outliers.R @@ -599,7 +599,7 @@ as.data.frame.check_outliers <- function(x, ...) { } #' @export -as.numeric.check_outliers <- function(x, ...) { +as.double.check_outliers <- function(x, ...) { attributes(x)$data$Outlier } diff --git a/tests/testthat/test-check_outliers.R b/tests/testthat/test-check_outliers.R index f037950c8..db31e000d 100644 --- a/tests/testthat/test-check_outliers.R +++ b/tests/testthat/test-check_outliers.R @@ -406,3 +406,10 @@ test_that("check_outliers with DHARMa", { ) ) }) + + +test_that("check_outliers with DHARMa", { + data(mtcars) + out <- check_outliers(mtcars$mpg, method = "zscore", threshold = 2) + expect_equal(which(as.numeric(out) == 1), c(18, 20)) +})