Shiny + DT:单细胞选择

Shiny + DT: Single Cell Selection

我正在尝试使用 DT 包的开发版本(可在 devtools::install_github('rstudio/DT') 获得)在闪亮的应用程序中启用单个单元格选择。我已经能够使用 selectiontarget 参数来选择单元格;但是,我不知道如何禁用多个被选中的单元格。 selection 参数列表是否有另一个参数允许我将用户的选择限制为最多 1 个单元格?如果没有,是否有其他方法可以完成单细胞选择?

如果有使用该版本软件包的更简单的解决方案,我非常愿意在 CRAN 上恢复到 DT 的稳定版本。

library(shiny)
library(DT)
data("mtcars")

ui <- shinyUI(
  fluidRow(
    DT::dataTableOutput("myDatatable"),
    verbatimTextOutput("selectedCells")
  )
)

server <- shinyServer(function(input, output, session) {
  output$myDatatable <- DT::renderDataTable(mtcars, 
                                            selection=list(target="cell"),
                                            server = FALSE,
                                            rownames=FALSE)

  output$selectedCells <- renderPrint(input$myDatatable_cells_selected)
})

shinyApp(ui, server)

问题出在您对 selection 列表中的 DT::renderDataTable 的调用中。你需要 selection=list(mode="single", target="cell")

modeselection(编辑前)

处设置单个或多个