Multiple conditions in condition panel R shiny

Is it possible to have multiple conditions when using conditionpanel in aa r shiny app? I want to hide a particular UI component for a couple of tabs. Below is what I am trying but it doesn't seem to be applying when I have multiple conditions:

 conditionalPanel(
      condition = "input.tab  !== 'nyc'||input.tab  !=='tokyo'",
    column(
      width = 3,
      pickerInput(
        inputId = "selected_metric",
        label = h4("Metric Name"),
        choices = c(
          "long Share",
          "short Share"
        ),

        width = "100%"
      )
    ))

The problem might be with the activation logic:

  • if tab is nyc, input.tab !=='tokyo' is true ==> active
  • if tab is tokyo, input.tab !=='nyc' is true ==> active
  • if tab is 'something else', input.tab !=='nyc' is true ==> active

I think you are looking for: condition = "input.tab !== 'nyc' && input.tab !== 'tokyo'"

  • if tab is nyc, input.tab !=='nyc' is false ==> not active
  • if tab is tokyo, input.tab !=='tokyo' is false ==> not active
  • if tab is 'something else', both conditions are true ==> active
2 Likes