Skip to content

Commit

Permalink
sanity_i allows logical matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Dec 12, 2024
1 parent 8fea197 commit da962fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/sanity.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ sanitize_i <- function(i, x, pre_group_i = FALSE, lazy = TRUE) {
if (is.character(i)) {
assert_choice(i, c("notes", "caption"))
return(i)
} else if (is.matrix(i) && is.logical(i)) {
return(i)
}
out <- seq_len(nrow(x))
assert_numeric(i, null.ok = TRUE, name = "i")
Expand Down
7 changes: 7 additions & 0 deletions inst/tinytest/test-i_j.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ tab <- tt(x) |>
format_tt(i = 3:4, j = c(5:6), num_fmt = "decimal", digits = 2)
expect_snapshot_print(tab, "i_j-format_tt_i_01")


cormat <- data.frame(cor(mtcars[1:5]))
tab <- tt(cormat, digits = 2) |>
style_tt(i = abs(cormat) > .8, background = "black", color = "white")
expect_equal(dim(tab), c(5, 5))


options(tinytable_print_output = NULL)

0 comments on commit da962fd

Please sign in to comment.