title: R: replacing predicted values with indicator values
body: <p>I have I have a matrix that's 19 mil predicted observations of <code>ID</code> and <code>Rating</code>. I want to replace the predicted <code>Rating</code> for <code>ID</code> that are in the actual <code>Rating</code>.</p>
  
  <p>Here is a demonstration of what I am trying to accomplish:</p>
  
  <pre><code>train &lt;- data.frame(1:10,c(1,2,NA,4,5,NA,7,8,NA,10))
  names(train) &lt;- c("ID", "Rating")
  pred &lt;- data.frame(1:10, c(1,1,3,4,2,4,5,6,7,1))
  names(pred) &lt;- c("ID", "Rating")
  </code></pre>
  
  <p>I want the final pred to be:</p>
  
  <pre><code>pred &lt;- data.frame(1:10, c(1,2,3,4,5,4,7,8,7,10))
  names(pred) &lt;- c("ID", "Rating")
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Attempt:</p>