title: In Shiny, select a salectInput choices by source() an .R document but dependent on the choices of another selectInput choices
body: <p>I would like to change the choices of a salectInput by sourcing (source()) an .R document but dependent on the choices of another selectInput.</p>
  
  <p>I have tried different options and read similar post but I do not get it working.</p>
  
  <p>I included a very simple UI with a code I originally thought would work.</p>
  
  <p>For this code the error is: Error in hasGroups(choices) : object 'input' not found</p>
  
  <p>Thanks very much in advance for the insights.</p>
  
  <pre><code>library(shiny)
  
  
  ui &lt;- # Define UI for dataset viewer application
  
    shinyUI(pageWithSidebar(
  
      headerPanel("Input Choices"),  
  
      sidebarPanel(
  
        selectInput(inputId = "Year", "Choose a Year:", 
  
                    choices = c("2012", "2011")),
  
        selectInput(inputId = "Cat", "Choose a Category:",   
                    choices =
                      if(input$Year == "2011") {
                      source("./Choices/Choices_OpB.R")
                      } else if (input$Year == "2012"){
                        source("./Choices/Choices_OpA.R")
                      }
                    ),    width = 2),
  
  
      mainPanel(
  
        tabsetPanel(type = "tabs", 
  
                    tabPanel("Html Pages")), width = 10)
  
    ))
  
  #
  
  
  server &lt;- shinyServer(function(input, output) {
  
  })
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Choices_OpB.R would be:</p>
  
  <pre><code>c("D", "E", "F")
  </code></pre>
  
  <p>Choices_OpA.R would be:</p>
  
  <pre><code>c("A", "B", "C")
  </code></pre>