【问题标题】:Bold row names of a formattable object可格式化对象的粗体行名称
【发布时间】:2019-03-30 00:11:01
【问题描述】:

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

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

如何修改它以加粗行名?

【问题讨论】:

    标签: r shiny formattable


    【解决方案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")))
                     )
    

    【讨论】:

    • 谢谢,顺便把列名加粗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 2016-01-02
    • 2018-12-21
    • 1970-01-01
    相关资源
    最近更新 更多