Reputation: 1217
I don't know exactly how to deal with this.
I have three buttons and I want that when the user select one of the buttons a checkbox appears with options and when the user changes the button the checkbox with the options change.
Example
actionButton("casos_button", "Casos", class = "btn-primary "),
actionButton("muertes_button", "Muertes", class = "btn-primary "),
actionButton("hospitalizados", "Hospitalizados", class = "btn-primary "),
If the user select the first button a check box appears with 3 options and if he select the second button then the options that correspond to the first button disappear and the checkbox options appear for the second button.
button 1 button 2 button 3
If the user select button 1 then a checkbox with 3 options appears If the user select button 2 then a checkbox with 4 options appears If the user select button 3 then a checkbox with 2 options appears
I am a noob with shiny and I really appreciate your helo
Upvotes: 1
Views: 264
Reputation: 10365
Here is a solution that uses shinyjs
to first hide the checkboxGroupInput
:
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
actionButton("button_1", "First Options"),
actionButton("button_2", "Second Options"),
hidden(checkboxGroupInput("options", "select the options", c("A", "B")))
)
server <- function(input, output, session) {
observeEvent(input$button_1, {
show("options")
updateCheckboxGroupInput(session,
"options",
choices = c("A", "B"))
})
observeEvent(input$button_2, {
show("options")
updateCheckboxGroupInput(session,
"options",
choices = c("C", "D"))
})
}
shinyApp(ui, server)
Upvotes: 1