title: How to select columns from a dataframe in Shiny if the user writes more than 1 column?
body: <p>I am trying to create an app where you are able to select the columns that you want to see.</p>
  <p>This post helped me a lot: <a href="https://stackoverflow.com/questions/46010595/shiny-how-to-dynamically-select-columns-of-imported-dataset-for-further-analysis">Shiny How to dynamically select columns of imported dataset for further analysis</a></p>
  <p>However, I want to be able to select the columns if the user doesn't click on the options and writes the columns who wants to see.</p>
  <p>Right now, in order to be able to select columns you need to click or write ONE column.</p>
  <p><a href="https://i.stack.imgur.com/unEAf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/unEAf.png" alt="image1" /></a></p>
  <p>However when you try to write more than 1 column (like this: &quot;cyl mpg hp&quot;, in the same line) it doesn't appear anything.</p>
  <p><a href="https://i.stack.imgur.com/5ar34.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ar34.png" alt="image2" /></a></p>
  <p>This is the code:</p>
  <pre><code>ui &lt;- fluidPage(
      
      # Application title
      titlePanel(&quot;Old Faithful Geyser Data&quot;),
      
      # Sidebar with a slider input for number of bins 
      sidebarLayout(
          sidebarPanel(
              selectInput(&quot;select&quot;, &quot;Select columns to display&quot;, c('col1,col2'), multiple = TRUE),
              actionButton(&quot;update&quot;, &quot;Update Data set&quot;, class = &quot;btn-primary&quot;,style='padding:4px; font-size:120%')
          ),
          
          # Show a plot of the generated distribution
          mainPanel(
              h2('The Mydata'),
              #tableOutput(&quot;mytable&quot;)
              DT::dataTableOutput(&quot;mytable&quot;)
              
          )
      )
  )
  
  library(shiny)
  library(DT)
  
  server &lt;- function(session, input, output) {
      
      data &lt;- reactive({
         mtcars
      })
      
      filtereddata &lt;- eventReactive({
          input$update
          data()
      },  {
          req(data())
          if(is.null(input$select) || input$select == &quot;&quot;)
              data() else 
                  data()[, colnames(data()) %in% input$select]
      })
      
      observeEvent(data(), {
          updateSelectInput(session, &quot;select&quot;, choices=colnames(data()))
      })
      
      output$mytable  &lt;- renderDataTable(filtereddata())
      
  } 
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>I have tried doing in another way, like here: <a href="https://shiny.rstudio.com/reference/shiny/1.6.0/varSelectInput.html" rel="nofollow noreferrer">https://shiny.rstudio.com/reference/shiny/1.6.0/varSelectInput.html</a> but I have the same problem.</p>
  <p>Thanks in advance</p>
  <p>Regards</p>