ElOwner
ElOwner

Reputation: 361

Shiny R checkboxGroupInput selected all

I have a checkboxGroupInput in my Shiny app with the following code :

checkboxGroupInput("sexe", "Sexe:",
c("Masculin" = "mas","Féminin" = "fem"))

My question is how to have them checked when first loaded?

knowing that I've tried selected= c but didn't work

Upvotes: 4

Views: 8458

Answers (1)

SymbolixAU
SymbolixAU

Reputation: 26258

use selected = c("mas","fem")

For example

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody( checkboxGroupInput("sexe","Sexe:", 
                                    choices = c("Masculin" = "mas", "Femenin" = "fem"),
                                    selected = c("mas","fem")))
)

server <- function(input, output){

}

shinyApp(ui, server)

enter image description here

Upvotes: 9

Related Questions