Question

I would like to display radio buttons in 2 different ways based on how many values are selected in a checkbox group. For example if my check box code is :

     checkboxGroupInput("ctype","Claim Type:" , c("CC" = "cc", "mc" = "mc", "md" = "md"), selected = NULL)

If only one ctype is selected then I would like to display the following :

    radioButtons("bygroup", "By Group",c("Size(GB)" = "Size.bytes."),selected = "Size.bytes.")

If more than one ctype is selected then I would like to display the following :

    radioButtons("bygroup", "By Group",c("Size(GB)" = "Size.bytes.", "Record Count(Mil)" = "Record_count", "PC(Mil)" ="UEC"),selected = "Size.bytes."))

I tried the following conditions in the conditional panel :

    conditionalPanel("length(input.ctype) > 1",radioButtons("bygroup",.....

It didn't work, any suggestions....

Was it helpful?

Solution

The condition needs to be written in javascript. length(input.ctype) should be input.cytpe.length

runApp(list(
  ui = bootstrapPage(
    checkboxGroupInput("ctype","Claim Type:" , c("CC" = "cc", "mc" = "mc", "md" = "md"), selected = NULL),
    conditionalPanel("input.ctype.length > 1",
                     radioButtons("bygroup", "By Group",c("Size(GB)" = "Size.bytes."),selected = "Size.bytes.")
    ),
    conditionalPanel("input.ctype.length <= 1",
                     radioButtons("bygroup", "By Group",c("Size(GB)" = "Size.bytes.", "Record Count(Mil)" = "Record_count", "PC(Mil)" ="UEC"),selected = "Size.bytes."))

  ),
  server = function(input, output) {
    output$plot <- renderPlot({ hist(runif(input$n)) })
  }
))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top