0

Assume I have three sidebarPanels, 'cond. 1', 'cond. 2' and 'treatment'.

I need to make the sidebarPanels (cond. 1 and cond. 2) disappear on choosing a value from the 'treatment' drop down menu.

If no value is chosen from treatment, I need to keep the cond. 1 and cond. 2.

How could this be done? Pl look at the screenshot for further reference.

Thanks!

Shiny Dashboard

Harriss
  • 13
  • 1
  • 8
  • 1
    take a look at the `hide()`/`show()`/`toggle()` functions in the shinyjs package – DeanAttali Jul 25 '16 at 20:21
  • There is a funciton called `conditionalPanel()`. That will help you. – four-eyes Jul 26 '16 at 08:07
  • @daattali : Seems like hide/show is possible only when something like an actionButton is present. Is it not possible to show/hide panels based on inputs from one of the other panels? – Harriss Jul 26 '16 at 16:14
  • @Harriss It is possible. hide/show/toggle can be called whenever you want in the server code, not just after a button click. You can make them depend on an input (you can use something like `toggle(id, condition = (input$num > 5))` to make it show/hide based on another numeric input) – DeanAttali Jul 26 '16 at 16:32
  • @daattali :On selecting any value from treatment panel, I want to make the cond1 and cond2 invisible, `toggle(c("cond1","cond2"), condition = input$treatment== c("a","b","c"))` Do you think this would help in the server script? – Harriss Jul 26 '16 at 16:46
  • You can certainly do something like that. But I'm pretty sure the code you suggested will not work, you probably want to use `%in%` instead of `==` for one thing. Play around with shinyjs and read the full documentation, you'll be able to use it in your app if you learn it – DeanAttali Jul 26 '16 at 16:50
  • @daattali: Thanks! – Harriss Jul 26 '16 at 16:52

0 Answers0