jeudi 15 juin 2023

CheckBox within CheckBox - R-Shiny

I have a bunch of checkboxGroupInput within my ui mainPanel like so

ui <- fluidPage(
    mainPanel = mainPanel(
        tabPanel(
    
            checkboxGroupInput("ID1", "Name1", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID1"),
            
            checkboxGroupInput("ID2", "Name2", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID2"),
            
            checkboxGroupInput("ID3", "Name3", choiceNames = list$a, choiceValues = list$b),
            uiOutput("conditionalInput_ID3")
    
        )
    )
)

The output within the server fct looks like so

  output$conditionalInput_ID1<- renderUI({
    if(!is.null(input$ID1)){
      if(any(input$ID1== "other")){
        textInput("ID1_other", "")
        }}
    })

  output$conditionalInput_ID2<- renderUI({
    if(!is.null(input$ID1)){
      if(any(input$ID12== "other")){
        textInput("ID2_other", "")
        }}
    })

  output$conditionalInput_ID3<- renderUI({
    if(!is.null(input$ID3)){
      if(any(input$ID3== "other")){
        textInput("ID3_other", "")
        }}
    })
  

ID1 - ID3 consists of a bunch of otption incl the option "other" with an additional textInput by choosing "other".

The reason for my question is, in ID1 are checkBoxes (lets call them ID1_a and ID1_b) for which i want ID2 to appear if ID1_a is choosen and ID3 to appear if ID1_b is chossen.

So basicly conditional checkboxes within checkboxes. Any ideas? Thx in advance!




Aucun commentaire:

Enregistrer un commentaire