I have a tukey results table that i would like to export while preserving the colourings :
I've tried :
png("test.png", height = 50*nrow(stat.test), width = 200*ncol(stat.test))
grid.table(stat.test)
dev.off()
I have a tukey results table that i would like to export while preserving the colourings :
I've tried :
png("test.png", height = 50*nrow(stat.test), width = 200*ncol(stat.test))
grid.table(stat.test)
dev.off()
Here's one option. This gives negative numbers a red background and positive numbers a green background instead of the font itself.
library(gt)
library(scales)
df <- data.frame(
group1 = c("Y", "1", "1", "2"),
estimate = c(-5.8,-7, 1, 2),
conf.low = c(-1,-10, 2, 3)
)
df |>
gt::gt() |>
data_color(
columns = c(estimate, conf.low),
colors = scales::col_bin(
bins = c(-Inf, 0, Inf),
palette = c("red", "green"),
)
) |>
gt::gtsave(filename = "test.png")
