title: Get row number for prediction with caret
body: <p>I use caret a lot for my machine learning tasks in R and I like it a lot.</p>
  
  <p>But I face the following problem:  </p>
  
  <ul>
  <li>I train a model in caret, say a linear regression with <code>lm()</code></li>
  <li>When I want to score new data, I do: <code>predict(model, new_data)</code></li>
  <li>When <code>new_data</code>contains missing values in my predictors, predict returns no prediction, instead of say <code>NA</code></li>
  </ul>
  
  <p>Is it possible to either:</p>
  
  <ul>
  <li>return a prediction for all rows in new_data with a prediction of <code>NA</code> when it is not possible or</li>
  <li>return predictions + the row number of the dataframe the prediction corresponds to?</li>
  </ul>
  
  <p>E.g. like the mlr-package does with an id-column that shows which row the prediction corresponds to:<br>
  <a href="https://i.stack.imgur.com/BDDIi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BDDIi.jpg" alt="enter image description here"></a></p>
  
  <p>Here is the link to the mlr-predict page with more details:
  <a href="https://mlr-org.github.io/mlr-tutorial/release/html/predict/index.html" rel="nofollow noreferrer">mlr-package: predict with row-id</a>  </p>
  
  <p>Any help greatly appreciated!</p>