title: Shiny algorithm help for showing/clearing filters based on dropdown
body: <p>I need help in determining an algorithm for dynamic filtering</p>
  
  <p>The algorithm should do:</p>
  
  <pre><code>1) Get the input region.csv from user
  2) Read list of countries and states from the input table
  3) Create a drop-down based on values (c("None", "Country,"State"))
  4) Now, when I click None- nothing should come, Country- Only country filter should appear, state-Both country and state. 
  5) When I click back Country or None, the existing filters of state or country should disappear based on selection.
  </code></pre>
  
  <p>I was able to do first 4 steps. But I couldn't clear the the existing filters when the user clicks back country or None. I tried conditional panels but couldn't accomplish this. Is there any easy way to do this?</p>
  
  <p>EDIT: Code and data</p>
  
  <p>Data: <a href="https://docs.google.com/spreadsheets/d/1E9dbtOMm1-7ZjIHu3Ra_NyFBHrCQdITG2_xuMIMKDOs/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1E9dbtOMm1-7ZjIHu3Ra_NyFBHrCQdITG2_xuMIMKDOs/edit?usp=sharing</a></p>
  
  <p>ui.r</p>
  
  <pre><code>library(shiny)
  
  shinyUI(fluidPage(
    navbarPage(
  
      "DumDum",
      tabPanel("Engine",
               bootstrapPage(
  
                 fileInput("file_attr", "Door attributes:"),
                 selectInput("select", label = "Level of Normalization", choices = list("None", "Country", "State"), selected = "None"),
  
                 uiOutput('output_values')
               )
      )
    )
  ))
  </code></pre>
  
  <p>server.r</p>
  
  <pre><code>library(shiny)
  
  shinyServer(function(input, output, session) {
  
  
    #Reading Input Files 
    data_attr &lt;- reactive({
      file1 &lt;- input$file_attr
      if(is.null(file1)){return()} 
      read.table(file=file1$datapath, sep=",", header = TRUE, stringsAsFactors = FALSE)    
    })
  
    #Filter interactivity
  
    #Reading Lists
    countries &lt;- reactive({
      if(is.null(data_attr()$Country)){return()}
      data_attr()$Country
    })
  
    states &lt;- reactive({
      if(is.null(data_attr()$State)){return()}
      data_attr()$State
    })
  
  
    #Filters based on Level of normalization
  
  
    observeEvent(input$file_attr,{
  
      output$output_values &lt;- renderUI({
        if (is.null(input$select)){return()}
  
        switch(input$select,
               "None" = h3("No normalization selected"),
               "Countries" = selectizeInput('show_vars', 'Country Filter', choices = c("Select All","None", unique(countries())), multiple = TRUE),
               "States" = selectizeInput('show_vars_state', 'State Filter', choices = c("Select All","None", unique(states())), multiple = TRUE))
      })
  
    })   
  
  })
  </code></pre>
  
  <p>Filters not appearing when user clicks "Country" in the drop-down field. Also, is there a way to make state filter disappear if we click Country (I mean if I click Country, only country filter should come; State- both Country and State filters should appear)</p>
  
  <p>Thanks</p>