【问题标题】:How to add row borders and zebra stripes (row striping) to datatables DT in R?如何在 R 中的数据表 DT 中添加行边框和斑马条纹(行条纹)?
【发布时间】:2015-04-15 13:49:55
【问题描述】:

我想知道将row borders stylingzebra stripes option 添加到使用R 中的包DT 创建的datatables 的正确方法。

简单的入门示例:

library(DT)
datatable(iris)

带有选项的简单示例:

datatable(head(iris, 20), options = list(
  columnDefs = list(list(className = 'dt-center', targets = 4)),
  pageLength = 5,
  lengthMenu = c(5, 10, 15, 20)
))

不知道为什么我收到了反对票?如果有任何不清楚的地方或如何改进这个问题,请告诉我。

【问题讨论】:

    标签: html r datatables border


    【解决方案1】:

    您可以将striperow-border 类添加到表容器中:

    library(DT)
    library(htmltools)
    datatable(
      head(iris, 20),
      container = tags$table(
        class="stripe row-border",
        tags$thead(tags$tr(lapply(colnames(iris), tags$th)))
      )
    )
    

    这将创建包含两个类的table 容器,并将应用样式功能。您可以从您发布的链接中添加任何其他样式。

    【讨论】:

    • 如何对列而不是行进行条带化?
    猜你喜欢
    • 2017-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 2011-04-04
    • 1970-01-01
    相关资源
    最近更新 更多