我有下面这个闪亮的仪表盘,我想知道我是否可以将列的单元格变成 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")
}
})
}
)