【发布时间】:2021-04-17 11:25:49
【问题描述】:
我使用R 中的shiny 和shinydashboard 包开发了一个仪表板。仪表板具有使用DT 包生成的datatable。在表格的顶部,有一个搜索框,允许用户通过输入来过滤表格的行。是否可以获取此输入并将其用于仪表板其他地方的反应式表达式?
这是一个玩具示例:
library(shiny)
library(shinydashboard)
library(DT)
shinyApp(
ui = shinyUI(
dashboardPage(
dashboardHeader(title = "Example"),
dashboardSidebar(sidebarMenu(id = 'tabs', menuItem("Tab1", tabName = 'Tab1'))),
dashboardBody(tabItems(tabItem(tabName = "Tab1",
fluidRow(column(width=6,box(DT::dataTableOutput('myTable'), width=NULL)),
column(width=6,box(textOutput("myText"), width=NULL))))))
)
),
server = function(input, output, session){
mytbl <- data.frame(Name = c('Matthew', 'Luke', 'John'), Grade=c(45, 20, 80))
output$myTable <- DT::renderDataTable({DT::datatable(mytbl, rownames=FALSE)})
output$myText <- renderText({ "The value entered in the seach box should appear here!" })
}
)
【问题讨论】:
标签: r shiny shinydashboard dt