【发布时间】:2017-01-21 21:16:50
【问题描述】:
【问题讨论】:
-
根据@yihue,您无法合并数据表中的单元格:github.com/rstudio/DT/issues/346
【问题讨论】:
这可以在datatables-rowsgroup library 的帮助下实现。这是一个例子:
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 中不可能做到这一点,我有另一种方法来实现它。
kable(c, align = "c") %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left",font_size = 12)%>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle")
请尝试一下,它可以工作:)
【讨论】: