[英]Shiny merge cells in DT::table on two or more columns
類似於這個問題: Shiny: Merge cells in DT::datatable
我想知道是否有辦法合並兩列或更多列。 在下面的示例中,僅合並第 1 列中的重復行,如果我還想合並每個部分中第 5 列中的重復行,該怎么辦。 例如,在表格的圖像中,我希望合並 Petal.Width 中的 0.2,以及 Petal.Width 中的 1.5。 那可能嗎?
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.