diff --git a/DESCRIPTION b/DESCRIPTION index cc2f60b71..7e5b390ae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: insight Title: Easy Access to Model Information for Various Model Objects -Version: 0.99.0.10 +Version: 0.99.0.11 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 7ca9e4d62..83b6e032f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -34,6 +34,9 @@ * `format_value()` gains a `decimal_point` argument, to change the decimal point in output conversion. +* `format_bf()` with `stars = TRUE` used the `°` symbol for inferiority + (evidence *against* the comparison). + ## Bug fix * `clean_parameters()` now uses the correct labels for the random effects diff --git a/R/format_bf.R b/R/format_bf.R index 6fa6da838..29f9686a3 100644 --- a/R/format_bf.R +++ b/R/format_bf.R @@ -11,7 +11,8 @@ #' @return A formatted string. #' #' @examples -#' format_bf(bfs <- c(0.000045, 0.033, NA, 1557, 3.54)) +#' bfs <- c(0.000045, 0.033, NA, 1557, 3.54) +#' format_bf(bfs) #' format_bf(bfs, exact = TRUE, name = NULL) #' format_bf(bfs, stars = TRUE) #' format_bf(bfs, protect_ratio = TRUE) @@ -82,6 +83,13 @@ format_bf <- function(bf, ) ) + ## Add stars + bf_text <- ifelse(bf_orig < (1 / 30), paste0(bf_text, "\u00B0\u00B0\u00B0"), + ifelse(bf_orig < 0.1, paste0(bf_text, "\u00B0\u00B0"), # nolint + ifelse(bf_orig < (1 / 3), paste0(bf_text, "\u00B0"), bf_text) # nolint + ) + ) + out <- .add_prefix_and_remove_stars(p_text = bf_text, stars, stars_only, name) if (is.na(na_reference)) out[bad_bf] <- "" out diff --git a/R/format_p.R b/R/format_p.R index fc6509cce..42e45c9a9 100644 --- a/R/format_p.R +++ b/R/format_p.R @@ -121,9 +121,10 @@ format_p <- function(p, } if (stars_only) { - p_text <- gsub("[^\\*]", "", p_text) + p_text <- gsub("[^(\\*|°)]", "", p_text) } else if (!stars) { p_text <- gsub("*", "", p_text, fixed = TRUE) + p_text <- gsub("\u00B0", "", p_text, fixed = TRUE) } # replace missing with related string diff --git a/tests/testthat/test-format.R b/tests/testthat/test-format.R index 8b15d912b..a135ff090 100644 --- a/tests/testthat/test-format.R +++ b/tests/testthat/test-format.R @@ -102,6 +102,30 @@ test_that("format_ci, character", { test_that("format others", { expect_type(insight::format_pd(0.02), "character") expect_identical(nchar(format_bf(4)), 9L) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54)), + c("BF < 0.001", "BF = 0.033", "", "BF > 1000", "BF = 3.54") + ) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54), name = NULL), + c("< 0.001", "0.033", "", "> 1000", "3.54") + ) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54), stars = TRUE), + c("BF < 0.001°°°", "BF = 0.233°", "", "BF > 1000***", "BF = 3.54*") + ) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54), stars = TRUE, stars_only = TRUE), + c("°°°", "°", "", "***", "*") + ) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54), protect_ratio = TRUE), + c("BF < 1/1000", "BF = 1/30.30", "", "BF > 1000", "BF = 3.54") + ) + expect_identical( + format_bf(c(0.000045, 0.033, NA, 1557, 3.54), protect_ratio = TRUE, exact = TRUE), + c("BF = 1/2.22e+04", "BF = 1/30.30", "", "BF = 1.56e+03", "BF = 3.54") + ) expect_type(format_rope(0.02), "character") })