下面的代码创建了一个小表。我不清楚如何进行这些更改:
1) 两个条之间的空白较少。使用 Inspect Element 我可以在 .table>tfoot>tr>td 中将填充从 8px 更改为 3px。这是正确的方法吗?如果是这样,如何将适当的 css 添加到我的 R 脚本中?
2) 去除彩条的圆角。同样,检查元素显示,如果我更改每个单元格的border_radius:0px 和padding-right:0px,就会发生更改。但是,这似乎也不正确。
3) 如何更改带有横条的单元格中文本的字体颜色?
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")