title: xgb.DMatrix Error: The length of labels must equal to the number of rows in the input data
body: <p>I am using xgboost in R.</p>
  
  <p>I created the xgb matrix fine using a matrix as input, but when I reduce the number in columns in the matrix data, I receive an error.</p>
  
  <p>This works:</p>
  
  <pre><code>&gt; dim(ctt1)
  
  [1] 6401 5901
  
  &gt; xgbmat1 &lt;- xgb.DMatrix(
       Matrix(data.matrix(ctt1)),
       label = as.matrix(as.numeric(data$V2)) - 1
    )
  </code></pre>
  
  <p>This does not:</p>
  
  <pre><code>&gt; dim(ctt1[,nr])
  
  [1] 6401 1048
  
  xgbmat1 &lt;- xgb.DMatrix(
      Matrix(data.matrix(ctt1[,nr])),
      label = as.matrix(as.numeric(data$V2)) - 1)
  </code></pre>
  
  <blockquote>
    <p>Error in xgb.setinfo(dmat, names(p), p[[1]]) : 
      The length of labels must equal to the number of rows in the input data</p>
  </blockquote>