代码之家  ›  专栏  ›  技术社区  ›  Hahnemann

在Shiny中传递ui中的小部件值

  •  0
  • Hahnemann  · 技术社区  · 8 年前

    在Shiny中,如何传递 selectInput 小部件到另一个小部件?这就是我想要实现的目标:

    selectInput("dataset", "",
                choices = c("A", "B", "C"), # A to C are datasets in memory
                selected = "B")
    
    conditionalPanel("input.tabs === 'tab'",
                     checkboxGroupInput("checkboxes", "",
                     names(?), # I want the column names of the selected dataset
                     selected = names(?))) # and here too
    

    具体来说,我想要 选择输入 ,可能是对内存中数据集的引用,由 checkboxGroupInput

    1 回复  |  直到 8 年前
        1
  •  1
  •   GyD    8 年前

    无论何时需要动态参数 ui ,您需要使用 uiOutput 结合 renderUI Read more

    用户界面。R

    用户界面 定义 UI输出 将在服务器端渲染的:

    selectInput("dataset", "",
                  choices = c("A", "B", "C"), # A to C are datasets in memory
                  selected = "B"),
    uiOutput("ui")
    

    服务器R

    在服务器端使用 伦德鲁 :

    output$ui <- renderUI( {
          conditionalPanel("input.tabs === 'tab'",
                           checkboxGroupInput("checkboxes", "",
                                              input$dataset,
                                              selected = input$dataset))
    })
    

    您可以使用访问选定值 input$dataset 。如果您需要 choices ,可以先将其存储在向量中,然后将其提供给两者 selectInput s