单击 DTdatatable 中的一个单元格并移动到闪亮应用程序的另一个选项卡

Click on a cell in DTdatatable and move to another tab of a shiny app

我在下面有闪亮的仪表板,我想知道我是否可以使列 Species 的单元格以某种方式交互,如果用户单击该列的一个词,例如 'setosa',移动到选项卡 Species

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(DT)
shinyApp(
  ui = dashboardPagePlus(
    header = dashboardHeaderPlus(
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      tabsetPanel(
        tabPanel("Documents",
                 DTOutput("dt1")),
        tabPanel("Species")
      )
    ),

  ),
  server = function(input, output) {
    library(readxl)

    output$dt1<-renderDT(
      iris,filter = "top",
      options = list(
        pageLength = 5
      )
    )

  }
)

请检查以下内容:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(DT)

shinyApp(
  ui = dashboardPagePlus(
    header = dashboardHeaderPlus(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(tabsetPanel(
      id = "myTabsetPanel",
      tabPanel("Documents",
               DTOutput("dt1")),
      tabPanel("Species")
    )),

  ),
  server = function(input, output, session) {
    output$dt1 <- renderDT(
      iris,
      filter = "top",
      options = list(pageLength = 5),
      selection = list(mode = 'single', target = 'cell')
    )

    observeEvent(input$dt1_cell_clicked, {
      # alternative: input$dt1_cells_selected
      if (req(input$dt1_cell_clicked$value) == "setosa") {
        updateTabsetPanel(session, inputId = "myTabsetPanel", selected = "Species")
      }
    })

  }
)