title: How to update columns based on another column
body: <p>I would like to know how to update the information of one column based on another column</p>
  <p>My example looks like</p>
  <pre><code>df &lt;- data.frame(input = c(&quot;Teline stenopetala&quot;, &quot;Teline stenopetala&quot;, 
                             &quot;Teline stenopetala&quot;, &quot;Prunus lusitanica&quot;, &quot;Prunus lusitanica&quot;),
                   n1 = c(&quot;Genista stenopetala Webb &amp; Berthel.&quot;, NA, NA, NA, &quot;Prunus hixa Brouss ex. Willd.&quot;))
  </code></pre>
  <p>The <code>df</code> includes the <code>input</code> column, and the 'n1' column whose values correspond to the <code>input</code> column's value.</p>
  <p>I would want to call in the event that I find any duplicated rows in the <code>input</code> column, the values that are blank in <code>n1</code> will be modified according to the value that is already present in <code>n1</code> associated with the value of the <code>input</code> column.</p>
  <p>Let's say the data is big so I would not want to call specific-name e.g. using <code>df %&gt;% mutate(n1 = case_when(input == &quot;Teline stenopetala&quot; ~ &quot;...&quot;</code></p>
  <p>My desired output here:</p>
  <pre><code>df &lt;- data.frame(input = c(&quot;Teline stenopetala&quot;, &quot;Teline stenopetala&quot;, 
                             &quot;Teline stenopetala&quot;, &quot;Prunus lusitanica&quot;, &quot;Prunus lusitanica&quot;),
                   n1 = c(&quot;Genista stenopetala Webb &amp; Berthel.&quot;, &quot;Genista stenopetala Webb &amp; Berthel.&quot;, &quot;Genista stenopetala Webb &amp; Berthel.&quot;, &quot;Prunus hixa Brouss ex. Willd.&quot;, &quot;Prunus hixa Brouss ex. Willd.&quot;))
  </code></pre>