I'm using the formattable package in R to produce a HTML table. I can use formatter to customise the look of data values in in my table e.g. font-size, color etc. But I can't work out how to alter the appearance of the table header row.I can alter the actual column names using col.names(), but haven't been able to change their appearance.
For example, in the table below how can I change the text color or background color in the header row (mpg, cyl, disp etc.)
Ultimately, I plan to use formattable::as.htmlwidget() and library(webshot) to grab an image file of the table, see Command for exporting/saving table made with Formattable package in R
Thanks
library(formattable)
formatRed <- formatter("span"
, style = x ~ style(color = ifelse(x > 21 , "red", "black")))
formatSize <- formatter("span"
, style = x ~ style("font-size" = "8px"))
exTb <- formattable(head(mtcars, 5)
, table.attr = "class='table table-striped'"
, list(mpg = formatRed
, wt = formatSize)
)
exTb