如何将行边界和斑马条纹(行条纹)添加到R中的数据表DT? [英] How to add row borders and zebra stripes (row striping) to datatables DT in R?
问题描述
我想知道添加行边界 样式和斑马条纹 选项 datatables 使用包中的 DT 在R中创建。
简单启动器示例:
库(DT)
pre>
datatable(iris)
选项简单示例:
datatable(head(iris ,20),options = list(
columnDefs = list(list(className ='dt-center',targets = 4)),
pageLength = 5,
lengthMenu = c(5, 10,15,20)
))
不知道为什么我收到投票?请让我知道如果有什么不清楚或如何改进这个问题。
解决方案你可以添加
stripe
和row-border
到表容器的类:库(DT)
库(htmltools)
datatable(
head(iris,20),
container = tags $ table(
class =stripe row-border,
tags $ thead(tags $ tr(lapply(colnames(iris),tags $ th)))
)
)
这将创建具有两个类和样式的
表
功能将被应用。您可以从您发布的链接中添加任何其他样式。I would like to know the proper way to add row borders styling and zebra stripes option to datatables created with the package DT in R.
Simple starter example:
library(DT) datatable(iris)
Simple example with options:
datatable(head(iris, 20), options = list( columnDefs = list(list(className = 'dt-center', targets = 4)), pageLength = 5, lengthMenu = c(5, 10, 15, 20) ))
Not sure why I received a down vote? Please let me know if anything is unclear or how to improve this question.
解决方案You can add the
stripe
androw-border
class to the table container:library(DT) library(htmltools) datatable( head(iris, 20), container = tags$table( class="stripe row-border", tags$thead(tags$tr(lapply(colnames(iris), tags$th))) ) )
This will create the
table
container with both classes and the styling feature will be applied. You can add any other styling from the link you posted.这篇关于如何将行边界和斑马条纹(行条纹)添加到R中的数据表DT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!