The code below creates a small table. It is unclear to me how to make these changes:
1) Less white space between the two bars. Using Inspect Element I can change the padding from 8px to 3px in .table>tfoot>tr>td. Is that the right approach? If so, how do I add the appropriate css to my R Script?
2) Remove the rounding of the color bars. Again, inspect element shows that if I change border_radius:0px and padding-right:0px for each cell the change occurs. But again, this doesn't seem correct.
3) How do I change the color of the font of the text in the cells that have the bars?
library(formattable)
library(kableExtra)
library(knitr)
fraction <- function(x, df) {
x/df$count
}
df <- tibble (
Type = c("A", "B", "C"),
count = c(500, 350, 860),
Decreasing = c(226, 103, 507),
Increasing = c(300, 250, 350)
)
mutate(df,
Decreasing = color_bar(color = "lightgrey", fun = "fraction", df)(Decreasing),
Increasing = color_bar(color = "lightgreen", fun = "fraction", df)(Increasing)
) %>%
select(Type, Decreasing, Increasing) %>%
kable("html", escape = "F", align = c("l", "r", "l")) %>%
kable_styling(bootstrap_options = c("striped", "hover", "responsive"), full_width = F, position = "float_left")