title: Error "invalid model formula in ExtractVars" in shiny
body: <p>This is my shiny UI image:
  <a href="https://i.stack.imgur.com/AEJcz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AEJcz.png" alt="enter image description here"></a></p>
  
  <p>global.R code:</p>
  
  <pre><code>library(shiny)
  library(gsheet)
  library(ggvis)
  library(ggplot2)
  
  urlA &lt;- "https://docs.google.com/spreadsheets/d/1lVVGg2iRLtOaizrkaJHtPCyEnQiKAnJPyNj1kSSPXvY/edit?usp=sharing"
  urlB &lt;- "Another URL"
  urlC &lt;- "Another URL"
  urlD &lt;- "Another URL"
  urlE &lt;- "Another URL"
  
  p_A &lt;- gsheet2tbl(urlA)
  p_B &lt;- gsheet2tbl(urlB)
  p_C &lt;- gsheet2tbl(urlC)
  p_D &lt;- gsheet2tbl(urlD)
  p_E &lt;- gsheet2tbl(urlE)
  
  paintingList &lt;- list(p_A, p_B, p_C, p_D, p_E)
  
  
  A_date &lt;- split(p_A, format(as.Date(p_A$date), "%Y-%m"))
  B_date &lt;- split(p_B, format(as.Date(p_B$date), "%Y-%m"))
  C_date &lt;- split(p_C, format(as.Date(p_C$date), "%Y-%m"))
  D_date &lt;- split(p_D, format(as.Date(p_D$date), "%Y-%m"))
  E_date &lt;- split(p_E, format(as.Date(p_E$date), "%Y-%m"))
  </code></pre>
  
  <p>server.R code:</p>
  
  <pre><code>shinyServer(function(input, output) {
    productInput &lt;- reactive({
    switch(input$painting,
           "A" = p_A,
           "B" = p_B,
           "C" = p_C,
           "D" = p_D,
           "E" = p_E)
  })
  
  output$paintDate &lt;- renderUI({
    if (input$painting == "A"){
      selectInput("pdate", "Select a date", names(split(p_A, format(as.Date(p_A$date), "%Y-%m"))))
  } else if(input$painting == "B") {
      selectInput("pdate", "Select a date", names(split(p_B, format(as.Date(p_B$date), "%Y-%m"))))
  } else if(input$painting == "C"){
      selectInput("pdate", "Select a date", names(split(p_C, format(as.Date(p_C$date), "%Y-%m"))))
  } else if(input$painting == "D"){
      selectInput("pdate", "Select a date", names(split(p_D, format(as.Date(p_D$date), "%Y-%m"))))
  } else if(input$painting == "E"){
      selectInput("pdate", "Select a date", names(split(p_E, format(as.Date(p_E$date), "%Y-%m"))))
  } else {
      return()
  }
  
  })
  
  output$paintplot &lt;- renderPlot({
    validate(need(input$pdate, ""))
    plot(as.formula(paste("date ~ ", input$pdate)), data = A_date)
  })
  </code></pre>
  
  <p>ui.R code:</p>
  
  <pre><code>shinyUI(fluidPage(
  includeCSS("css/main.css"),
  navbarPage("Plot",
             tabPanel("ggPlot",
                      sidebarLayout(
                        sidebarPanel(
                          #add choices
                          selectInput("painting", "Select a option:",
                                      choices = c("A", "B", "C", "D", "E")),
                          uiOutput("paintDate")
                        ),
  
                        mainPanel(
                            plotOutput("paintplot"))
                        )
                     )
             ))
  ))
  </code></pre>
  
  <p>The error message:</p>
  
  <blockquote>
    <p>Warning: Error in terms.formula: invalid model formula in ExtractVars</p>
  </blockquote>
  
  <p>I want to select the data in a column and the display plot.</p>
  
  <p>How to show my selection in plot?</p>
  
  <p>Reference example: <a href="http://shiny.rstudio.com/gallery/unicode-characters.html" rel="nofollow noreferrer">http://shiny.rstudio.com/gallery/unicode-characters.html</a></p>
  
  <p>Please help me. Thanks.</p>