title: Error in Training Multiple Models using caret package
body: <p>I am facing a very confusing problem while using the caret package in R. For a comparison, I am training multiple models. After a few calls to train, this error message begins to show for which ever train call / train model I use:-</p>
  
  <blockquote>
    <p>Error in UseMethod("train") : no applicable method for 'train' applied to an object of class "formula"</p>
  </blockquote>
  
  <p>Once this error appears, no other model is trained but the above error appears instead.</p>
  
  <p>When I restart R and load the caret package again, the same models for which this error appeared, get trained easily.</p>
  
  <p>I am confused as to what seems to be the issue here?</p>
  
  <p>I have made a function for the 5 training models I try to create:-</p>
  
  <pre><code>test = function(){
  
  a = train(demand ~ temp, oldData, 'lm')
  print("Done A")
  
  b = train(demand ~ temp, oldData, 'rf', ntree = 10)
  print("Done B")
  
  c = train(demand ~ temp, data = oldData, method = "gbm", 
          trControl = objControl, tuneGrid = gbmGrid, verbose = F)
  print("Done C")
  
  d = train(demand ~ temp, oldData, 'mlp')
  print("Done D")
  
  e = train(demand ~ temp, oldData, 'monmlp')
  print("Done E")
  }
  </code></pre>
  
  <p>P.S: Although, I have trained all these models successfully, I am trying to create an ensemble function for which I intend to run all these calls together.</p>