title: Error: variables specified with different types from the fit in shiny
body: <p>I am trying to create a shiny app which uses classification algorithm to predict a response variable. There is no problem with the model or the <code>predict</code> function when ran on R. However, incorporated in shiny, it gives the following error:</p>
  
  <p><code>Error: variables ‘X1’, ‘X2’, ‘X3’ were specified with different types from the fit.</code></p>
  
  <p>Here is the data I created to simplify the problem:</p>
  
  <pre><code>data1 &lt;- data.frame(replicate(1,sample(c("a","b"), 1000, rep = TRUE)),
                  replicate(3, sample(0:1, 1000, rep = TRUE)))
  colnames(data1)[1] &lt;- "outcome"
  </code></pre>
  
  <p>where variable "outcome" is the response variable and "X1", "X2" and "X3" are the predictors.</p>
  
  <p>The model I've trained is as following;</p>
  
  <pre><code>modelFit &lt;- train(outcome ~ ., data  = data1, method  = "glm")
  </code></pre>
  
  <p>This is the Server.R</p>
  
  <pre><code>library(shiny)
  library(caret)
  library(shinyapps)
  shinyServer(function(input, output){
    modelFit &lt;- readRDS("modelFit.Rds")    
    userdf &lt;- data1[1,]
    values &lt;- reactiveValues()
    values$df &lt;- userdf
    newEntry &lt;- observe({
      values$df$X1 &lt;- input$X1
      values$df$X2 &lt;- input$X2
      values$df$X3 &lt;- input$X3})
    output$results &lt;- renderPrint({
      ds1 &lt;- values$df
      a &lt;- predict(modelFit, newdata = data.frame(ds1))
      names(a) &lt;- NULL
      cat(a)
    })
  })
  </code></pre>
  
  <p>and the UI.R is</p>
  
  <pre><code>library(shiny)
  shinyUI(fluidPage(
    tags$head(
      tags$style(HTML("
                    @import url('//fonts.googleapis.com/css?family=Lobster|Cabin:400,700');
                    h1 {
                    font-family: 'Lobster', cursive;
                    font-weight: 500;
                    line-height: 1.1;
                    color: #48ca3b;
                    }
                    "))
      ),
  # Application title
    titlePanel(" Predictor",
             windowTitle = "random Predictor"),
    h5("Just for Fun"),
  
    sidebarLayout(sidebarPanel(
      hr(),
      h5('Enter parameters for prediction:'),
      hr(),
      selectInput("X1", 
                   label = h6("Numer of Bronze Badges"), 
                   choices = unique(data1$X1)),
      selectInput("X2", 
                   label = h6("Numer of Silver Badges"), 
                   choices  = unique(data1$X2)),
      selectInput("X3", 
                  label = h6("Numer of blue Badges"), 
                  choices  = unique(data1$X3))
  
    ),  #ends sidebarPanel
  
    mainPanel(
      tabsetPanel(
        tabPanel("Results", h2("The output is"),
                 h2(verbatimTextOutput("results")),
                 h2(" answers to your question."),
                 p(), "Note:" , p(), "Look for it"))
        )
    )
  ))
  </code></pre>
  
  <p>Thanks in advance for the help.</p>