I would like to display a slider (in below example, bins) in the sidepanel only if a certain radio button is selected (in below example, y).
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
width = 3,
radioButtons("modify_hist", "Modify histogram?", choices=c("Yes"="y", "No"="n"), selected="y"),
# display below sliderInput only if input$modify_hist=="y"; otherwise do not display below sliderInput
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)),
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server)
(No need to hide the plot for this example.)
I tried selecting input$modify_hist in the sidebarPanel but that didn't work.
Any pointers are appreciated. Thank you!