可格式化对象的粗体行名称

Bold row names of a formattable object

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

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

如何修改它以将行名称加粗?

这个怎么样? 我必须做一个 "dirty trick":我将行名称添加为一列,然后将其命名为“”,所以它没有显示......但我认为它可以解决问题:

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