title: Replace value in data frame with value from other data frame based on set of conditions
body: <p>In df1 I need to replace values for msec with corresponding values in df2.</p>
  
  <pre><code>df1 &lt;- data.frame(ID=c('rs', 'rs', 'rs', 'tr','tr','tr'), cond=c(1,1,2,1,1,2), 
  block=c(2,2,4,2,2,4), correct=c(1,0,1,1,1,0), msec=c(456,678,756,654,625,645))
  
  df2 &lt;- data.frame(ID=c('rs', 'rs', 'tr','tr'), cond=c(1,2,1,2), 
  block=c(2,4,2,4), mean=c(545,664,703,765))
  </code></pre>
  
  <p>In df1, if <code>correct==0</code>, then reference <code>df2</code> with the matching values of <code>ID</code>, <code>cond</code>, and <code>block</code>. Replace the value for <code>msec</code> in <code>df1</code> with the corresponding value for <code>mean</code> in <code>df2</code>.</p>
  
  <p>For example, the second row in df1 has <code>correct==0</code>. So, in <code>df2</code> find the corresponding row where <code>ID=='rs'</code>, <code>cond==1</code>, <code>block==2</code> and use the value for mean (<code>mean=545</code>) to replace the value for msec (<code>msec=678</code>). Note that in df1 combinations of ID, block, and cond can repeat, but each combination occurs only once in df2.</p>