这是我正在使用的formattable对象的最小示例:
library(formattable)
formattable(mtcars,
align = "c",
list(~ formatter("span",
style = x ~ formattable::style(display = "block",
"border-radius" = "2px",
"padding" = "5px",
"text-align" = "center"))))
如何修改它以加粗行名?
答案 0 :(得分:1)
这个怎么样? 我不得不做一个“肮脏的把戏”:我将行名添加为一列,然后将其命名为“”,这样就不会显示出来了……但是我认为这可以解决问题:
library(formattable)
mtcars$model <- rownames(mtcars)
rownames(mtcars) <- c()
mtcars <-mtcars[,c(12,c(1:11))]
colnames(mtcars)[1] = " "
formattable(mtcars,
align = "c",
list(~ formatter("span",
style = x ~ formattable::style(display = "block",
"border-radius" = "2px",
"padding" = "5px",
"text-align" = "center")),
` ` = formatter("span",style = ~ style(display = "block",
"border-radius" = "2px",
"padding" = "5px",
"font.weight" = "bold",
"text-align" = "left")))
)