pickerInput
can be made to initialize with all choices selected by passing the choice list into the selected
box as follows:
library(shiny)
choice_list <- c("Tom", "Hank", "Kelly")
ui <- fluidPage(
pickerInput(inputId = "grp_sel",
label = "Select Groups",
choices = choice_list,
selected = choice_list,
multiple = T)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
However, I would like to do this with a list of choices as follows but this is not working. Can anyone tell me what a solution is to this?
choice_list <- list("Group A" = c("Tom", "Jenny", "Kim"),
"Group B" = c("Hank", "James", "Kelly"))
ui <- fluidPage(
pickerInput(inputId = "grp_sel",
label = "Select Groups",
choices = choice_list,
selected = choice_list,
multiple = T)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
CodePudding user response:
If you pass a vector instead of a list all choices will be selected: selected = unlist(choice_list)