lundi 30 janvier 2017

Unchecked box using checkboxInput in Shiny

I am trying to get my Shiny app to do one of two things based on the checked status of a checkboxInput.

When the box is checked, I can get my code to work. However, I can't figure out how to make unchecking the box lead to a unique result.

How do I do this?

Below is a reproducible example. - In this example, unchecking the box leads to an error reading "argument is of length zero."

library(shiny)

ui <-  fluidPage(
  checkboxGroupInput(inputId = "test.check", label = "", choices = "Uncheck For 2", selected = "Uncheck For 2"),
  verbatimTextOutput(outputId = "test")
)

server <- function(input, output) {

  output$test <- renderPrint({
    if(input$test.check == "Uncheck For 2") {
      1
    } else {
      2
    }
  })


}

shinyApp(ui = ui, server = server)




Aucun commentaire:

Enregistrer un commentaire