I have a dataframe column that I\'m currently formatting using the formattable::color_tile function (below):
color_tile( \"red\", \"springgreen\"
In an issue' entry of the github' formattable site, I found this which seems useful and solved my problem to have a column color coded on continuous scale from negative to positive as red to green, without having the "brown" in the middle (this will deliver "transparent"):
library(dplyr)
library(kableExtra)
library(formattable)
x = currency(c(1000000,
-3000,
400000,
800000,
-1700,
0,
50000))
x = ifelse(
x <= 0.0,
color_tile("red", "transparent")(x*c(x<=0)),
color_tile("transparent", "green")(x*c(x>=0)))
x %>%
kable(escape = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"),
full_width = F)
This is the relevant link: https://github.com/renkun-ken/formattable/issues/102#issuecomment-408649019