jeudi 4 janvier 2018

Selecting choices of checkBoxGroup based on created data

I am working on a Shiny App where I created some data in different places and I would like to use a checkBoxGroup to list the data that are already created or not.

So let imagine there are 3 data and 2 are already created, these two should have the tick on and empty the one which is still null. Here below my guess which is not working.

Thanks in advance

if (interactive()) {

  ui <- fluidPage(
    checkboxGroupInput("inCheckboxGroup", "Input checkbox",c("data A", "data B", "data C"))
  )

  server <- function(input, output, session) {
    data_A <- NULL
    data_B <- 1
    data_C <- 3

    observe({
      a <- data_A
      b <- data_B
      c <- data_C

      selectedBox <- which(!c(is.null(a),is.null(b),is.null(c)))
      updateCheckboxGroupInput(session, "inCheckboxGroup2",
                               choices = c("Data A", "Data B", "Data C"),
                               selected = selectedBox
      )
    })
  }

  shinyApp(ui, server)
}




Aucun commentaire:

Enregistrer un commentaire