I need to change the background colour of the headers of a table printed with knitr::kable. I can use kableExtra::column_spec
to change the background of a whole column, but it doesn't affect the header row:
library(knitr)
library(kableExtra)
kable(data.frame(a = 1, b = 2)) %>%
column_spec(1, background = "yellow")
Wanted outcome:
A kable
output where the header of column a
has a yellow background (and the rest of the table a white background).