diff --git a/DESCRIPTION b/DESCRIPTION index e77d42255..88671c4bd 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.19.8.6 +Version: 0.19.8.7 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NAMESPACE b/NAMESPACE index 106f444de..0296c2b0e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -339,7 +339,9 @@ S3method(find_weights,model_fit) S3method(format,insight_formula) S3method(format,n_grouplevels) S3method(format_ci,bayestestR_ci) +S3method(format_ci,character) S3method(format_ci,data.frame) +S3method(format_ci,factor) S3method(format_ci,numeric) S3method(format_string,character) S3method(format_string,data.frame) diff --git a/NEWS.md b/NEWS.md index 257a97670..cc619b354 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ * Fixed issue in `find_predictors()` for models with splines (`s()`), where number of dimensions was indicated with a variable, not a number. +* `format_ci()` now works for factors and character vectors again. + # insight 0.19.8 ## General diff --git a/R/format_ci.R b/R/format_ci.R index 468cc50de..3c8c9480b 100644 --- a/R/format_ci.R +++ b/R/format_ci.R @@ -157,6 +157,11 @@ format_ci.numeric <- function(CI_low, } } +#' @export +format_ci.factor <- format_ci.numeric + +#' @export +format_ci.character <- format_ci.numeric # bayestestR objects ------------------------------------------------------ diff --git a/tests/testthat/test-format.R b/tests/testthat/test-format.R index cbb07e787..4fe67bb58 100644 --- a/tests/testthat/test-format.R +++ b/tests/testthat/test-format.R @@ -82,6 +82,21 @@ test_that("format_ci, parameters", { ) }) +test_that("format_ci, factor", { + data(iris) + expect_identical( + format_ci(iris$Species[1], iris$Species[100]), + "95% CI [setosa, versicolor]" + ) +}) + +test_that("format_ci, character", { + expect_identical( + format_ci("a", "c"), + "95% CI [a, c]" + ) +}) + test_that("format others", { expect_type(insight::format_pd(0.02), "character") expect_identical(nchar(format_bf(4)), 9L)