Closed
Description
It would be great to be able to color one column based on the value of another - i.e. to specify a different target for data_color
. Various SO discussions (e.g., here and here) have failed to come up with a solution, and #637 would need to be addressed to restore a (not very intuitive) workaround.
A possible desired code (and illustration for a use-case that I regularly encounter) would be the following, though something else might fit better in the gt API.
library(gt)
data <- data.frame(cat = LETTERS[1:3],
M_SD = c("1.1 (0.7)", "3.5 (0.6)", "2.0 (0.7)"),
M = c(1.1, 3.5, 2.0))
# DESIRED code
gt(data) %>%
cols_hide(3) %>%
data_color(SOURCE_columns = 3, TARGET_columns = 2,
colors = scales::col_numeric(palette = c("red", "green"), domain = c(1, 4)))
Metadata
Metadata
Assignees
Type
Projects
Status
Done