Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 109

How to fill entire cell of a table with cell_spec() in kabeleExtra?

$
0
0

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()

Viewing all articles
Browse latest Browse all 109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>