如何将行边界和斑马条纹(行条纹)添加到R中的数据表DT? [英] How to add row borders and zebra stripes (row striping) to datatables DT in R?

查看:166
本文介绍了如何将行边界和斑马条纹(行条纹)添加到R中的数据表DT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道添加行边界 样式斑马条纹 选项 datatables 使用包中的 DT 在R中创建。



简单启动器示例:

 库(DT)
datatable(iris)
pre>

选项简单示例:

  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 and row-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆