Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny R checkboxGroupInput selected all

Tags:

r

shiny

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

like image 670
ElOwner Avatar asked Oct 26 '25 19:10

ElOwner


1 Answers

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

like image 164
SymbolixAU Avatar answered Oct 29 '25 07:10

SymbolixAU



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!