5

这是我正在使用的可格式化对象的最小示例:

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

如何修改它以加粗行名?

4

1 回答 1

4

这个怎么样?我不得不做一个“肮脏的把戏”:我将行名添加为一列,然后将其命名为“”,所以它没有显示出来......但我认为它是诀窍:

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

在此处输入图像描述

于 2019-03-30T08:34:51.863 回答