Skip to content

Commit

Permalink
add back format_ci for factor/character
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 4, 2024
1 parent 88416db commit b51927e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions R/format_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-format.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b51927e

Please sign in to comment.