title: Changing select input choices in r Shiny
body: <p>I am trying to build an app using Shiny. It will contain 2 dropdowns, one will show the name of 7 different sectors- it,bank,steel,fmcg etc. The other dropdown should contain list of name of companiesof selected sector, i.e list of names will be dynamic.</p>
  
  <p>1.I am not getting any idea about how to change list of names of 2nd dropdown dynamically, for eg. if we select "IT" 2nd dropdown should contain "infosys" ,"tcs" etc, if we select "Bank", 2nd dropdown musr show "SBI","ICICI" etc.</p>
  
  <p>ui.R</p>
  
  <pre><code>library(shiny)
  shinyUI(fluidPage(
  titlePanel("Forecasting of stock prices and their accuracies"),
  
  sidebarLayout(
  sidebarPanel(
  radioButtons("rd",
               label="Select time range for training dataset",
               choices=list("23 month","18 month","12 month","6 month"),
               selected="23 months"),
  
  selectInput("sector",
              label="select a sector",choices=list("IT"=1,"Bank"=2,"Power"=3,"Steel"=4,        
  "FMCG"=5,"Infrastructure"=6,"Automobile"=7 ),                  
              selected=1),
  
  
  selectInput("stock",
              label="select a option",choices=list("co.1"=1,"co.2"=2,
  "co.3"=3,"co.4"=4,"co.5"=5,"
  co.6"=6,"co.7"=7,"co.8"=8),
              selected=1)
  
  ),
  mainPanel("Display results",
          textOutput("summary"),
          tableOutput("view"))
  )
  ))
  </code></pre>
  
  <p>server.R</p>
  
  <pre><code>shinyServer(function(input, output) {
  datasetInput &lt;- reactive({
   if(input$sector=="1"){
   switch(input$stock, 
                 "1" = Infy,
                 "2" = TCS,
                 "3" = Wipro,
                 "4" = TechM)}
  
   else if(input$sector=="2"){
     switch(input$stock, 
            "1" = SBIN,
            "2" = ICICI,
            "3" = HDFC,
            "4" = Axis,
            "5" = IDBI,
            "6" = PSB,
            "7" = BOI,
            "8" = Bob
     )}
  })
  
  output$view&lt;-renderTable({
   head(datasetInput(),n=10)
  })
  
  })
  </code></pre>