gtExtras
gtExtras copied to clipboard
gt_badge conditional on variables
Prework
- [x] Search for duplicates among the existing issues (both open and closed).
Proposal
It would be nice to be able to set badges on only certain rows of a gt table. For instance, here's an example with missings
d <- tibble::tribble(
~a, ~b,
"a", 1,
"b", 2,
"c", NA,
"d", NA,
)
gt(d) |>
gt_badge(b,
palette = c("red", "blue", "green")) |>
sub_missing(missing_text = "")
There are two issues here. Firstly, the <br />
tag, which I guess might be a bug, and secondly, the badge itself on those <br />
tags, which would rather be blank instead.
It would be great to be able to do something like
gt(d) |>
gt_badge(b,
palette = c("red", "blue"),
rows = !is.na(b)) |>
sub_missing(missing_text = "")