my_color_fun <- function(x) {
out <- rep("yellow", length(x))
out[x < quantile(x, .75)] <- "pink"
out[x < quantile(x, .50)] <- "wheat"
out[x < quantile(x, .25)] <- "gray90"
out
}
ft <- flextable(head(mtcars, n = 10))
ft <- highlight(ft, j = "disp", i = ~ disp > 200, color = "yellow")
ft <- highlight(ft, j = ~ drat + wt + qsec, color = my_color_fun)
ft
Run the code above in your browser using DataLab