Rhiny:将几个uiOutput(“select”)/ SelectInput()与conditionalPanel()结合使用

时间:2016-03-18 08:08:22

标签: shiny-server shiny

我全新的Shiny App有一个sidePanel,带有两个动态SelectInput()函数。根据哪个Panel处于活动状态,应使用相应的uiOutput(“select”)动态SelectInput。我读过这可以用conditionalPanel()来完成 - 但我无法弄清楚如何...我发现的结果中没有组合uiOutput(“select”)/ SelectInput(),所有都直接在窗格中使用SelectInput ...

请,任何人都可以帮助我,我如何更改代码以包含conditionalPanel() - 如果这是必要的。非常感谢任何建议和帮助!!!!

ui.R

shinyUI(fluidPage(
  titlePanel('Table Overviews'),
sidebarPanel(
  uiOutput("select1"),
  br(),
  uiOutput("select2")
),
mainPanel(
  tabsetPanel(
    tabPanel("Panel 1", 
             fluidRow(
               column(6, h4("Tablel"), tableOutput("Table1")),
               column(6, div(style = "height:300px")),
               fluidRow(
                 column(6,h4("Table2"), tableOutput("Table2")),
                 column(6,h4("Table3"), tableOutput("Table3")))
             )), 
    tabPanel("Panel 2", 
             fluidRow(
               column(6, h4("Table4"), tableOutput("Table4")),
               column(6, div(style = "height:300px")),
               fluidRow(
                 column(6,h4("Table5"), tableOutput("Table5")),
                 column(6,h4("Table6"), tableOutput("Table6")))
             ))
  )

server.R

shinyServer(function(input,output){
## two different SelectInputs to select from two different lists 
output$select1 <- renderUI({
selectInput("dataset1", "Overview1", as.list(files1))
 })

 output$select2 <- renderUI({
 selectInput("dataset2", "Overview2", as.list(files2))
 })


 ## Output of the first SelectInput
 output$Table1 <- renderTable({
    f1 <- function1(input$dataset1)
 f1[[1]]
 })

 output$Table2 <- renderTable({
  f1 <- function1(input$dataset1)
  f1[[2]]
 })

 output$Table3 <- renderTable({
  f1 <- function1(input$dataset1)
  f1[[3]]
 })

 # Output of the second SelectInput
 output$Table4<- renderTable({
  f2 <- function2(input$dataset2)
  f2[[3]]
 })

 output$Table5 <- renderTable({
  f2  <- function2(input$dataset2)
  f2[[2]]
 })

 output$Table6 <- renderTable({
  f2  <- function2(input$dataset2)
  f2[[1]]
 })
 })

1 个答案:

答案 0 :(得分:0)

终于明白了 - 它非常简单。感谢所有关于我的各种问题的评论,非常感谢大家!!!

需要在UI.R中更改所有内容:

  conditionalPanel(condition="input.conditionedPanels == Panel 1",       
                   uiOutput("select_twb")),
  br(),
  conditionalPanel(condition="input.conditionedPanels == Panel 2",       
                   uiOutput("select_twbx"))
相关问题