闪亮:合并DT :: datatable中的单元格 [英] Shiny: Merge cells in DT::datatable
本文介绍了闪亮:合并DT :: datatable中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想合并DT :: datatable中闪亮的列中的几行。
当前我能够输出如下所示的内容:
< a href = https://i.stack.imgur.com/IqAnT.png rel = noreferrer>
但理想情况下,我希望合并行并希望输出以下内容:
是否可以在DT :: datatable中合并这样的行?
解决方案
可以在
I would like to merge few rows in column in DT::datatable in shiny. Is it possible to do so?
Currently I am able to output which looks something like this:
But ideally I would like to merge the rows and want to output something like this:
Is it possible to merge rows like this in DT::datatable?
解决方案
It is possible with the help of the datatables-rowsgroup library. Here is an example:
library(shiny)
library(DT)
dat <- iris[c(1,2,3,51,52,53,101,102,103), c(5,1,2,3,4)]
ui <- fluidPage(
DTOutput("table")
)
server <- function(input, output){
output[["table"]] <- renderDT({
dtable <- datatable(dat, rownames = FALSE,
options = list(
rowsGroup = list(0) # merge cells of column 1
))
path <- "U:/Data/shiny/DT/www" # folder containing dataTables.rowsGroup.js
dep <- htmltools::htmlDependency(
"RowsGroup", "2.0.0",
path, script = "dataTables.rowsGroup.js")
dtable$dependencies <- c(dtable$dependencies, list(dep))
dtable
})
}
shinyApp(ui, server)
这篇关于闪亮:合并DT :: datatable中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文