title: Using [R] packages caret and gbm: "Error in vector(type, length) : vector: cannot make a vector of mode 'NULL'"
body: <p>I'm trying to train a boosting model on a data frame, using the Caret and gbm packages in R. I've been able to build models successfully with default parameters; however, I continue to hit this error, when I attempt to customize the summary function:</p>
  
  <pre><code>Error in vector(type, length) : 
    vector: cannot make a vector of mode 'NULL'.
  </code></pre>
  
  <p>This is the first question I've posted, as I'm usually able to root up info to solve the problem. In this case, I can't seem to find a similar issue. </p>
  
  <p>The following code is intended to reproduce the error. Let me know if it doesn't, or if I should include additional info, as I'm more than happy to do so. </p>
  
  <p><strong>System.info:</strong><br>
  <strong>sysname</strong>: Windows<br>
  <strong>release</strong>: 7 x64<br>
  <strong>version</strong>: build 7601, Service Pack 1<br>
  <strong>version.string</strong>: R version 3.1.3 (2015-03-09)<br>
  <strong>system</strong>: x86_64, mingw32</p>
  
  <pre><code>library(plyr)
  library(caret)
  library(dplyr)
  
  example &lt;- data.frame(response = rnorm(100), predictor1 = rnorm(100), predictor2 = rnorm(100))
  
  aeSummary &lt;- function(data, lev = NULL, model = NULL) {
      out &lt;- abs(data$obs-data$pred)
      names(out) &lt;- "AE"
      out
   }
  
  modelFit &lt;- train(response ~ ., 
                data = example,
                method = "gbm", 
                tuneGrid = data.frame(n.trees = 5, 
                                      interaction.depth = 5, 
                                      shrinkage = 0.05, 
                                      n.minobsinnode = 6),
                metric = "AE", 
                maximize = FALSE, 
                trControl = trainControl(
                        summaryFunction = aeSummary))
  </code></pre>