title: How to update choice of select input in r shiny dynamically
body: <p>I am developing a shiny app where the choices of select input should update dynamically based earlier inputs.</p>
  
  <p>For example if both category and segment are selected in 1st input widgets and only skin_care in 2nd input widgets then Medicated and Non medicated 
  should come as option in 3rd input widgets not all the unique names of segment. 
  If hair_care slected instead of skin_care in 2nd input widgets then Gents and Ladies should be choice in 3rd input widgets dropdown.
  So basically the choice to select from drop down is dependent on what user seleted on earlier input widgets. Same goes for brand also.
  Here I am assuming the seletcion of dimension is always from left to right. </p>
  
  <p>The actual app will ask user to load data and it can have 10 dimensions or may be more.I kept three for simplicity.  </p>
  
  <pre><code>library(shiny)
  library(DT)
  
  ui &lt;- shinyUI(fluidPage(
  tabsetPanel(
  tabPanel("Data", fluid = TRUE,
           sidebarLayout(
             sidebarPanel(p("Please remove None first"),
                          uiOutput("dim"),
                          uiOutput("levels1")),
             mainPanel(
               DT::dataTableOutput("data_display")
             ))))))
  
  server &lt;- shinyServer(function(input,output){
  
  # creating Data 
  data &lt;- reactive({
  data &lt;-  data.frame(Date = as.Date(c("2018-05-25","2018-05-26")),
              category = c(rep("skin_care",6),rep("hair_care",6)),
              Segment =  c(rep("Medicated",4),rep("Non_Medicated",2),
                         rep("Ladies",4),rep("Gents",2)),
              Brand = c("X","X","Y","Y","Z","Z","A","A","B","B","C","C"),
              sales = round(rnorm(12,100,3)))
  })
  
  
  # Displaying Data  
  
  output$data_display &lt;- DT::renderDataTable(                    
  datatable(data(),options = list(pageLength = 12),rownames = FALSE)
  )
  
  # selects dimension (Only character variable to be selected)
  
  output$dim&lt;-renderUI({
  b&lt;-colnames(data()[sapply(data(),class)=="character"])
  selectInput("x","Select only character variable",choices = 
                c("NONE",b[1:length(b)]),selected="NONE",multiple = TRUE)
   })
  
   #  user selects levels of dimension 
  
  output$levels1&lt;-renderUI({
  if(is.null(input$x)){
    return(NULL)
  }
  else if(sum(input$x=="NONE")==1){
    return(NULL)
  }
  else{
    lapply(seq(input$x),function(i){
      selectInput(inputId = paste0("range",i),
                  paste0("Select level of ",input$x[i]),
                  choices = c(unique(data()[,input$x[i]]),"ALL"),multiple = TRUE)
  
     })
    }
   })
   })
  shinyApp(ui,server)
  </code></pre>
  
  <p><strong>EDIT:</strong> Provided option in dropdown in dynamically appearing selectinput widgets </p>