Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pickerInput default select all choices

Tags:

r

shiny

I have about a dozen pickerInputs, and each time I run my shiny app, everything is set to nothing selected. I have to manually select everything before the output works which is a little annoying. Is there a way for pickerInput to default to "select all" each time the app runs?

like image 453
mistersunnyd Avatar asked Aug 14 '18 23:08

mistersunnyd


Video Answer


1 Answers

You can use the selected argument of pickerInput. Just pass all your choices to selected, which will choose everything when the app initializes. Setting action-box option to True will also build Select All & Deselect All buttons by default, which would improve your current workflow. Here is a minimal example:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  pickerInput(
    inputId = "my_input",
    label = "TEST",
    choices = 1:10,    # provide choices - integers from 1 to 10
    selected = 1:10,   # select - integers from 1 to 10 
    options = list(`actions-box` = TRUE),   # build buttons for collective selection
    multiple = T
  )
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)
like image 141
Ozan Avatar answered Oct 11 '22 19:10

Ozan