title: Replace values of a column based on another column having as input a dataframe
body: <p>With the <code>base::replace</code> function I want to change some values of column <code>z</code> based on the values of column <code>y</code></p>
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  
  (df &lt;- tibble(y = 10:13, z = 20:23))
  #&gt; # A tibble: 4 x 2
  #&gt;       y     z
  #&gt;   &lt;int&gt; &lt;int&gt;
  #&gt; 1    10    20
  #&gt; 2    11    21
  #&gt; 3    12    22
  #&gt; 4    13    23
  </code></pre>
  <p>I have the data.frame <code>val</code> where column <code>a</code> the value to be used as condition and column <code>b</code> will be the replacement value.</p>
  <pre class="lang-r prettyprint-override"><code>(val &lt;- tibble(a = c(10, 12), b = c(100, 200)))
  #&gt; # A tibble: 2 x 2
  #&gt;       a     b
  #&gt;   &lt;dbl&gt; &lt;dbl&gt;
  #&gt; 1    10   100
  #&gt; 2    12   200
  </code></pre>
  <p>Using the following approach it is possible to get the desired result, but it only works if <strong>all</strong> the values inside <code>val</code> are inside <code>df</code></p>
  <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate(z = replace(z, y %in% val$a, val$b))
  #&gt; # A tibble: 4 x 2
  #&gt;       y     z
  #&gt;   &lt;int&gt; &lt;dbl&gt;
  #&gt; 1    10   100
  #&gt; 2    11    21
  #&gt; 3    12   200
  #&gt; 4    13    23
  </code></pre>
  <p>For example, if I update <code>val</code> to have values that are <strong>not</strong> in <code>df</code>, then:</p>
  <pre class="lang-r prettyprint-override"><code>(val &lt;- tibble(a = c(1, 10, 12), b = c(1, 100, 200)))
  #&gt; # A tibble: 3 x 2
  #&gt;       a     b
  #&gt;   &lt;dbl&gt; &lt;dbl&gt;
  #&gt; 1     1     1
  #&gt; 2    10   100
  #&gt; 3    12   200
  </code></pre>
  <p>and I run the code again ...</p>
  <pre class="lang-r prettyprint-override"><code>df %&gt;% mutate(z = replace(z, y %in% val$a, val$b))
  #&gt; Warning in x[list] &lt;- values: number of items to replace is not a multiple of
  #&gt; replacement length
  #&gt; # A tibble: 4 x 2
  #&gt;       y     z
  #&gt;   &lt;int&gt; &lt;dbl&gt;
  #&gt; 1    10     1
  #&gt; 2    11    21
  #&gt; 3    12   100
  #&gt; 4    13    23
  </code></pre>
  <p>There are errors ... How can I fix this?</p>
  <p><sup>Created on 2021-02-19 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v1.0.0)</sup></p>