如何在R Shiny中创建带有复杂标题的数据表? [英] How to create datatable with complex header in R Shiny?

查看:64
本文介绍了如何在R Shiny中创建带有复杂标题的数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在


I have a datatable in R Shiny and would like to have headers that span multiple columns like below:

How can this be achieved in R Shiny?

解决方案

Theres already example http://rstudio.github.io/DT/

library(DT)
sketch = htmltools::withTags(table(
  class = 'display',
  thead(
    tr(
      th(rowspan = 2, 'Species'),
      th(colspan = 2, 'Sepal'),
      th(colspan = 2, 'Petal')
    ),
    tr(
      lapply(rep(c('Length', 'Width'), 2), th)
    )
  )
))
datatable(iris[1:20, c(5, 1:4)], container = sketch, rownames = FALSE)

这篇关于如何在R Shiny中创建带有复杂标题的数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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