title: different number of column name in selectIput Shiny
body: <p>I have one problem with create dynamic UI (<code>selectInput</code>). I mean, I have two <code>dataframes</code> and one <code>selectInput</code> button which should change number of output (column name) depending on dataframe which I choose.
  I just get error: <code>Error: == only defined for equally-sized data frames</code> when I choose <code>df2</code> dataframe. Could anyone tell me what I do wrong? <br>This is my <code>if</code> function:</p>
  
  <pre><code>  output$xvars &lt;- renderUI({
      if (datasetInput() == df1){
        axis_vars_x &lt;- colnames(df1[c(1,2)])
        selectInput("xvar", "X-axis variable", axis_vars_x, selected = "id")
      }
      else{
        axis_vars_x &lt;- colnames(df2[1])
        selectInput("xvar", "X-axis variable", axis_vars_x, selected = "id")
      }
    })
  </code></pre>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>library(dplyr)
  library(shiny)
  library(ggvis)
  
  shinyUI(fluidPage(
  
  titlePanel("Old Faithful Geyser Data"),
  
  sidebarLayout(
   sidebarPanel(
    radioButtons("dataset", label = h4("Product level"),
                 choices = list("Item" = "df1", "Task" = "df2")),
    uiOutput("xvars"),
    ),
   mainPanel(
    ggvisOutput("plot")
    )
   )
  ))
  </code></pre>
  
  <p><strong>server.R</strong></p>
  
  <pre><code>library(shiny)
  library(dplyr)
  
  df1 &lt;- data.frame(id = c(1,2,3,4,5), number = c(20,30,23,25,34), ds =  c(1,2,3,42,2))
  df2 &lt;- data.frame(id = c(1,2), number = c(33,40), ds = c(1,2))
  
  shinyServer(function(input, output) {
  
   datasetInput &lt;- reactive({
    switch(input$dataset,
           df1 = df1,
           df2 = df2)
   })
  
   output$xvars &lt;- renderUI({
      if (datasetInput() == df1){
        axis_vars_x &lt;- colnames(df1[c(1,2)])
        selectInput("xvar", "X-axis variable", axis_vars_x, selected = "id")
      }
      else{
        axis_vars_x &lt;- colnames(df2[1])
        selectInput("xvar", "X-axis variable", axis_vars_x, selected = "id")
      }
    })
  
   data &lt;- reactive({
   df &lt;- datasetInput()
   })
  
  vis &lt;- reactive({
   data %&gt;%
    ggvis(~id, ~number) %&gt;%
    layer_points(fill = ~factor(id)) %&gt;%
    scale_nominal("fill", range = c("red","blue","green","yellow","black"))
  
  })
  vis %&gt;% bind_shiny("plot")
  })
  </code></pre>