reactablefmtr
reactablefmtr copied to clipboard
`color_tiles()` ignores `colDef`s `na=` argument
I wanted to use color_tiles
and came across the issue that it ignores the na=
argument from colDef
and prints out the missing values as NA
.
library(reactable)
library(reactablefmtr)
library(dplyr)
tile_column <- function(x) {
colDef(
show = TRUE,
na = "",
cell = color_tiles(
x,
colors = c("red", "orange", "yellow", "limegreen", "green"),
number_fmt = scales::percent_format(scale = 1, accuracy = .1, decimal.mark = ",", big.mark = "."),
box_shadow = TRUE,
)
)
}
data <- tibble(
col1 = c(1, 4, 2, 5, NA_integer_, 2),
col2 = c(2, 1, 2, NA_real_, NA_real_, 2),
)
data |> reactable() ## works -> no NAs are printed
data %>%
reactable(
columns = list(
col1 = tile_column(.),
col2 = tile_column(.)
)
) ## does not work
Can you please have a look and maybe fix this?
Note that in my real application I still want to be able to color a tile by another column although its label is NA
. The tile should not vanish entirely.