Search code examples
rflexdashboard

Selecting all values from drop down menu in Flexdashbaord


I have taken a sample code of one of the Shiny Flexdashboard. In the sample code there is a drop down menu to select one region at a time. I just want to know is there a way to select all the values in the drop down menu?

Kindly find the code in below link,

beta.rstudioconnect.com/jjallaire/shiny-embedding

for code, click "Source Code" on the top extreme right.

Regards,

Mohan


Solution

  • You can do

    library(shiny)
    ui = fluidPage(
      selectInput("sel", NULL, letters[1:2], multiple = T),
      actionButton("but", "all")
    )
    server <- function(input, output, session) {
      observeEvent(input$but, {
        updateSelectInput(session, "sel", selected = letters[1:2])
      })
    }
    shinyApp(ui, server)
    

    Use ?updateSelectInput to access the documentation on that function.