print.check_outliers() mislabels thresholds when method is a combination given in non-canonical order
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- r
- Domain
- devtools, testing-qa
Research direction
The bug is in the print method in R/check_outliers.R. Look at the data.frame construction where method and thresholds are combined; the order of thresholds from attr(x, 'threshold') does not match the user's method order. Start by reading the function print.check_outliers, then trace how thresholds are stored. Run the reproducible example to confirm the mismatch, and ensure the printed summary pairs each method with its correct threshold.
Written by the indexing model from the issue text.
Description
When check_outliers() is run with a single method (e.g. "mcd"), the printed threshold is correct. When run combining several methods (e.g. c("mcd", "lof", "iqr"), the printed summary line pairs each method name with the wrong threshold value if the user's method order differs from the package's internal default order.
Each method correctly uses its own threshold internally, but there seems to be a display bug in the printed message.
Reproducible example:
library(performance)
data(mtcars)
# With a single methods, it works ok
check_outliers(mtcars, method = "mcd")
#> Based on the following method and threshold: mcd (31.264)
# Combined methods — mislabeled
check_outliers(mtcars, method = c("mcd", "lof", "iqr"))
#> Based on the following methods and thresholds: mcd (2), lof (31.264), iqr (0.001)
I suspect that the root cause may be in print.check_outliers() (R/check_outliers.R):
thresholds <- lapply(attr(x, "threshold"), round_to_last_digit, 3)
method.thresholds <- data.frame(
method = method, # this keeps the order given by the user
thresholds = unlist(thresholds) # this keeps the order given by the package
)
Let me know if I can help with this!
sessionInfo()
R version 4.5.0 (2025-04-11 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=Spanish_Argentina.utf8
[2] LC_CTYPE=Spanish_Argentina.utf8
[3] LC_MONETARY=Spanish_Argentina.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Spanish_Argentina.utf8
time zone: America/Buenos_Aires
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods
[7] base
other attached packages:
[1] performance_0.18.2
loaded via a namespace (and not attached):
[1] jsonlite_2.0.0 dplyr_1.2.0 compiler_4.5.0
[4] renv_1.0.11 Rcpp_1.1.1 tidyselect_1.2.1
[7] tidyr_1.3.2 DiagrammeR_1.0.12 yaml_2.3.10
[10] fastmap_1.2.0 dbscan_1.2.6 R6_2.6.1
[13] generics_0.1.4 igraph_2.3.2 knitr_1.50
[16] htmlwidgets_1.6.4 MASS_7.3-65 visNetwork_2.1.4
[19] backports_1.5.0 tibble_3.3.1 insight_1.5.4
[22] pillar_1.11.1 RColorBrewer_1.1-3 rlang_1.1.7
[25] cachem_1.1.0 xfun_0.55 datawizard_1.4.0
[28] memoise_2.0.1 cli_3.6.5 magrittr_2.0.4
[31] digest_0.6.37 rstudioapi_0.17.1 lifecycle_1.0.5
[34] vctrs_0.7.1 dm_1.1.2 evaluate_1.0.3
[37] glue_1.8.0 rmarkdown_2.29 purrr_1.2.1
[40] tools_4.5.0 pkgconfig_2.0.3 htmltools_0.5.8.1
- Dominant language
- R
- Stars
- 1.2k
- Forks
- 109
- Avg merge
- 8h 28m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from easystats/performance
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
easystats/performance#937 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
easystats/performance#936 · 2 comments ·
-
Bug :bug:
Difficulty 3/5 1-2 days Newbie friendliness 56/100
easystats/performance#916 · 1 comment ·
-
Enhancement :boom:
Difficulty 3/5 1-2 days Newbie friendliness 48/100
easystats/performance#908 ·
-
Multiple intercepts in multinomial logistic regression currently ignored in check_collinearity() OpenBug :bug:
Difficulty 3/5 1-2 days Newbie friendliness 68/100
easystats/performance#907 · 1 comment ·
All issues in easystats/performance
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
briandconnelly/airnow#9 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OHDSI/CohortConstructor#774 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
pre-review R TeX Track: 5 (DSAIS)
Difficulty 1/5 Under an hour Newbie friendliness 60/100
openjournals/joss-reviews#11330 · 7 comments ·