【问题标题】:Rhiny: combine several uiOutput("select") / SelectInput() with conditionalPanel()Rhiny:将几个 uiOutput("select") / SelectInput() 与 conditionalPanel() 结合起来
【发布时间】:2016-03-18 17:04:55
【问题描述】:

我全新的 Shiny App 有一个带有两个动态 SelectInput() 函数的侧面板。根据哪个面板处于活动状态,应使用相应的 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")))
             ))
  )

服务器.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]]
 })
 })

【问题讨论】:

    标签: shiny-server shiny


    【解决方案1】:

    终于弄明白了——真的很简单。感谢各位cmets为我提出的各种问题,非常感谢大家!!!

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

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

    【讨论】:

      猜你喜欢
      • 2018-09-21
      • 2021-09-28
      • 2020-04-02
      • 2018-07-27
      • 2014-04-05
      • 2020-01-19
      • 2011-11-17
      • 2012-12-12
      • 2012-06-29
      相关资源
      最近更新 更多