格式表对象的粗体行名称

时间:2019-03-30 00:11:01

标签: r shiny formattable

这是我正在使用的formattable对象的最小示例:

library(formattable)
formattable(mtcars, 
            align = "c",
            list(~ formatter("span",
                             style = x ~ formattable::style(display = "block",
                                                            "border-radius" = "2px",
                                                            "padding" = "5px",
                                                            "text-align" = "center"))))

如何修改它以加粗行名?

1 个答案:

答案 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")))
                 )

enter image description here