0

Consider the following:

ui.R:

library(shiny)

shinyUI(fluidPage(

  shinyjs::useShinyjs(),

  checkboxGroupInput("Check1",label=h4 ("Fish:"), choices = c("Bass","Shark","Tuna")),
  conditionalPanel(condition = "input.Check1 == 'Bass'",
    checkboxGroupInput("Check2",label=h4 ("Bass Types:"), choices = c("A","B","C"))
  )
))

server.R:

library(shiny)

shinyServer(function(input, output) {

})

enter image description here

When Bass is checked, the new checkbox appears. Great.

enter image description here

But, if I were to select Shark as well, the Bass Types checkbox group disappears.

enter image description here

I would like to keep the Bass Types checkbox there as long as Bass is selected (so it should remain visible if Shark is selected).

I have already tried condition = "'Bass' %in% input.Check1".

Clarinetist
  • 1,097
  • 18
  • 46
  • I don't use `shiny`, but if the condition argument to `conditionalPanel` uses R syntax, then changing `condition = "input.Check1 == 'Bass'"` to `condition = "'Bass' %in% input.Check1"` should be the right logic. – lmo Aug 25 '16 at 13:12
  • @lmo Unfortunately I've already tried that. Thanks, though. – Clarinetist Aug 25 '16 at 13:13
  • Its a good idea to include what you have already tried in your question in order to reduce redundancy. – lmo Aug 25 '16 at 13:14
  • 1
    @lmo I think it uses JavaScript, after further research. Do you happen to know any JavaScript? – Clarinetist Aug 25 '16 at 13:19
  • Unfortunately, I haven't had the pleasure, but maybe [this post](http://stackoverflow.com/questions/36631803/check-for-element-in-array?noredirect=1&lq=1) and the links it contains will help. – lmo Aug 25 '16 at 13:24
  • @lmo I have marked the question as a duplicate. – Clarinetist Aug 25 '16 at 13:39

0 Answers0