title: Look for cell within a data frame and replace its value without loops R
body: <p>Using this df:</p>
  
  <pre><code>  DF = data.frame(m=rep(1:2,2), y=rep(1998:1999,each=2), A=c(2:5), B=c(4,NA,6,7))
  
  &gt; DF
    m    y A  B
  1 1 1998 2  4
  2 2 1998 3 NA
  3 1 1999 4  6
  4 2 1999 5  7
  </code></pre>
  
  <p>How could I replace a single cell using as coordinates this values:</p>
  
  <pre><code>m = 2 ; y = 1999 ; col = 'A' ; val = 72
  </code></pre>
  
  <p>Following those values I want to replace 5 with 72.</p>
  
  <hr>
  
  <p><strong>Edit.</strong>
  As testing all the answers I realized my question is very basic and don't represent my problem. I tried to do it without for loops but failed and eventually used it.</p>
  
  <p>So, I want to replace values within the <code>DF</code> data frame but using this other data frame:</p>
  
  <pre><code>repl = data.frame(m=c(2,1), y=c(1999,1998), col=c('A','B'), val=c(72,100))
  &gt; repl
    m    y col val
  1 2 1999   A  72
  2 1 1998   B 100
  </code></pre>
  
  <p>This means that each row of the <code>repl</code> data frame is a value to replace in <code>DF</code>.</p>
  
  <p>I've been trying to use Psidom answer <code>mutate(A = replace(A, m == 2 &amp; y == 1999, 72)</code> for each row but wonder if can be done without loops or without using column names.</p>
  
  <p>Thank you. </p>