Following on from this question posed a while ago, does anyone know how I can fill the entire background of a cell using the cell_spec()
function in kableExtra
?
I have some dummy data below, but I can only manage to colour the background of the text. I'd prefer the entire cell filled and I'm pretty set on using kableExtra
to create my table within an R Markdown file. Does anyone know of a workaround for this? Thanks.
library(kableExtra)name <- paste("Name", LETTERS)val <- rnorm(26, 100, 50)d <- data.frame(name, val)d$val <- cell_spec(d$val, background = if_else(d$val > mean(d$val) + sd(d$val),"#DBEBF6", if_else(d$val < mean(d$val) - sd(d$val),"#FEE7DA","transparent")))kbl(d, escape = FALSE) %>% kable_styling()