I want to use checkboxGroupInput and then, if a certain box is checked, i want a conditionalPanel. A toy example is here:
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
checkboxGroupInput("items","Which Item?",
choices=c("A","B","C","D")),
conditionalPanel( condition = "input.items == 'D'",
numericInput("n","n",value=50,min=0,max=100,step=1)
)
),
mainPanel(
uiOutput("text")
)
)
))
now this works fine if only box 'D' is selected, but not if (as would be normal in my problem) several boxes are selected.
in server.R something like
if("D" %in% input$which)
works fine but that does not seem to work in ui.R. I also tried subsetting ala R, for example
conditionalPanel( condition = "input.items[4] == 'D'",
but that does not work either.
Wolfgang
docendo gave the correct answer: the syntax is
conditionalPanel(condition = "input.items.includes('D')"
Thanks!
somehow it no longer works with shiny v1.1.0. I am using R version 3.5.1 with platform windows. Rather than the includes()
solution, the below works well for me (just in case others encounter the same issue):
conditionalPanel(condition = "input.items.indexOf('D') > -1", ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With