Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R如何构建动态条件面板_R_Shiny - Fatal编程技术网

R如何构建动态条件面板

R如何构建动态条件面板,r,shiny,R,Shiny,例子 sidebarPanel( selectInput( "plotType", "Plot Type", c(Scatter = "scatter", Histogram = "hist")), # Only show this panel if the plot type is a histogram conditionalPanel( condition = "input.plotType == 'hist'",

例子

sidebarPanel(
   selectInput(
      "plotType", "Plot Type",
      c(Scatter = "scatter",
        Histogram = "hist")),

   # Only show this panel if the plot type is a histogram
   conditionalPanel(
      condition = "input.plotType == 'hist'",
      selectInput(
         "breaks", "Breaks",
         c("Sturges",
           "Scott",
           "Freedman-Diaconis",
           "[Custom]" = "custom")),

      # Only show this panel if Custom is selected
      conditionalPanel(
         condition = "input.breaks == 'custom'",
         sliderInput("breakCount", "Break Count", min=1, max=1000, value=10)
      )
   )
)
大家好。这是conditionalPanel()类型的示例

我想知道如何在conditionalPanel()中使用selectInput的输出

例如,我想要一个这样的程序:

 condition = "input.plotType == 'input$plotType'",
      selectInput( -- here -- depends on the input)
a a1
a a2
a a3
b b1
b b2
c c1
c c2
d d1
d d2 
d d3
我的输入如下:

 condition = "input.plotType == 'input$plotType'",
      selectInput( -- here -- depends on the input)
a a1
a a2
a a3
b b1
b b2
c c1
c c2
d d1
d d2 
d d3
我想在a、b、c和d之间进行选择,之后,如果我选择a,我想在a1、a2、a3之间进行选择,如果我选择b,ecc,我想在b1和b2之间进行选择

我可以手工做,但我有很多变量和动态子分布

谢谢

看看renderUI()

用户界面端:

conditionalPanel(
      condition = "input.plotType == 'hist'",
      uiOutput("fromServer")
),
服务器端:

output$fromServer <- renderUI({
   ## Now you can use inputs like input$plotType to build your selectInput
   selectInput(
         "breaks", "Breaks",
         c("Sturges",
           "Scott",
           "Freedman-Diaconis",
           "[Custom]" = "custom"
    )
})
output$fromServer