Home > OS >  ConditionalPanel in shiny isn't responding
ConditionalPanel in shiny isn't responding

Time:12-29

tabPanel("Incidence",
   sidebarLayout(
      sidebarPanel(
             selectInput(
                       "incidence", "Select Cancer Incidence Rates By:",
                        choices = c("Age" = "I_Age",
                                    "Cancer Type" = "I_Site",
                                    "Trends" = "I_Trend",
                                    "Trend By Age" = "I_Tr_Age",
                                    "Admission Type" = "I_Admin",
                                    "Stage" = "I_Stage",
                                    "Stage By Age" = "I_St_Age",
                                    "Cancer Detected By Screening" = "I_Screen",
                                                   )
                                     ),
                                     conditionalPanel(
                                       condition = "input.incidence !== 'Trend By Age' || 
                                                    input.incidence !== 'Stage By Age' || 
                                                    input.incidence !== 'Cancer Type'",
                                    selectInput("gender","Gender",
                                                   choices = unique(table$Gender))
                                     )

I am trying to condition the gender panel where I don't want gender inputs for trend by age, stage by age, and cancer type. I am not sure where I am wrong. Could someone please help me with this?

CodePudding user response:

As @amanwebb points out, just replace || operators for &&:

library(shiny)

ui <- fluidPage(
  #tabPanel("Incidence",
           sidebarLayout(
             sidebarPanel(
               selectInput(
                 "incidence", "Select Cancer Incidence Rates By:",
                 choices = c("Age" = "I_Age",
                             "Cancer Type" = "I_Site",
                             "Trends" = "I_Trend",
                             "Trend By Age" = "I_Tr_Age",
                             "Admission Type" = "I_Admin",
                             "Stage" = "I_Stage",
                             "Stage By Age" = "I_St_Age",
                             "Cancer Detected By Screening" = "I_Screen")
               ),
               conditionalPanel(
                 condition = "input.incidence !== 'I_Tr_Age' && input.incidence !== 'I_St_Age' && input.incidence !== 'I_Site'",
                 selectInput("gender","Gender", choices = c("aer", "aer2"))
                 )
               ), mainPanel()
))

server <- function(input, output, session) {
  
}

shinyApp(ui, server)
  • Related