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

Format Text Within color_bar {formattable}

$
0
0

I am formatting a table using formattable:color_bar and would like to add a comma as a thousands separator as well as adjust the colour of the font.

For cells where I don't use color_bar I see how I can use cell_spec to change the font color but I don't know how to do it with cells that are using color_bar.

library(tidyverse)library(knitr)library(kableExtra)library(formattable)df <- tibble (  rank = c(1,2,3),  tree = c("Norway Maple", "Honey Locust", "Colorado Blue Spruce"),  number = c(74688, 24286, 21917))df %>%   mutate(    tree = cell_spec(tree, "html", color = "black"),    number = color_bar()(number)) %>%   kable("html", escape = F,  align = c("l", "l")) %>%  kable_styling(bootstrap_options = c("hover", "responsive", "condensed"), full_width = F, position = "float_left")  %>%  column_spec(3, width = "10cm")

Viewing all articles
Browse latest Browse all 105

Trending Articles



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