title: Shiny, can't choose variable of a selected dataset
body: <p>In my app I want user to choose between two dataset (mtcars and iris), then to choose one variable from previously chosen dataset. The app will show the summary of that variable.</p>
  <p>I can choose the dataset, however a problem arises when I'm trying to choose the variable - everytime I choose something, it returns to the first column available (eg. while choosing Iris as a db I can see only Sepal.Length). For a brief moment summary can be seen for that chosen variable</p>
  <pre><code>library(shiny)
  library(dplyr)
  db_cars &lt;- mtcars
  db_iris &lt;- iris
  
  # Define server logic required to summarize and view the selected dataset
  server &lt;- shinyServer(function(input, output, session) {
    datasetInput &lt;- reactive({
      simple_name &lt;- eval(as.symbol(paste(input$dataset))) 
      observe({
        updateSelectInput(
          session,
          &quot;variable&quot;, 
          choices = colnames(simple_name[1:ncol(simple_name)]) 
        )
      })
      simple_name %&gt;% pull (input$variable)
    })
    output$summary &lt;- renderPrint({
      dataset &lt;- datasetInput()
      summary(dataset)
    })
  })
  
  # Define UI for dataset viewer application
  ui &lt;- shinyUI(pageWithSidebar(
    headerPanel(&quot;Shiny Text&quot;),
    sidebarPanel(    
      selectInput(&quot;dataset&quot;, &quot;Choose dataset&quot;, 
                  choices = c(&quot;db_cars&quot;, &quot;db_iris&quot;)),
      selectInput(&quot;variable&quot;, &quot;Choose variable&quot;, 
                  choices = &quot;&quot;),
    ),
    mainPanel(
      verbatimTextOutput(&quot;summary&quot;),
    )
  ))
  
  shinyApp(ui = ui, server = server)
  </code></pre>