Reputation: 85
Examples
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)
)
)
)
Hi everyone. This is the example of conditionalPanel() typing ?
I would like to know how can I use the output of the selectInput inside conditionalPanel().
For example I want a program like this:
condition = "input.plotType == 'input$plotType'",
selectInput( -- here -- depends on the input)
My input is like this:
a a1
a a2
a a3
b b1
b b2
c c1
c c2
d d1
d d2
d d3
I would like to choose between a,b,c and d and after I would like to choose between a1,a2,a3 if i chosed a, b1 and b2 if I chosed b, ecc.
I could do it by hand but I have a lot of variables and a dynamic sub-distribution.
Thank you
Upvotes: 1
Views: 1263
Reputation: 17689
Have a look in renderUI().
ui side:
conditionalPanel(
condition = "input.plotType == 'hist'",
uiOutput("fromServer")
),
server side:
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"
)
})
Upvotes: 1