Вы можете попробовать что-то подобное в своем блоке knitr R:
suppressPackageStartupMessages(invisible(
lapply(c("dplyr", "knitr", "kableExtra", "scales"),
require, character.only = TRUE)))
x <- data.frame(a = c(0.1, 0.2, 0.4),
b = c(0.3, 0.5, 0.7),
c = c(0.8, 0.9, 0.5))
xc <- seq(min(x), max(x), length.out = 10)
pal <- seq_gradient_pal("#e9f7cb", "#1b7378")(xc)
setSpec <- function(y){
kableExtra::cell_spec(y, "latex", background = pal[cut(y, breaks=xc, include.lowest = TRUE)])
}
apply(x, 2, setSpec) %>% knitr::kable("latex", escape = FALSE, booktabs = TRUE, linesep = "")