title: Refactorising this code within a loop in R
body: <p>I wish to write a loop which removes all values from each year column, one at a time, if the value specified in Start Year is greater than that in the named year column. </p>
  
  <pre><code>X &lt;- X %&gt;%
    mutate(`2017` = ifelse(as.numeric(`Start Year`) &gt; 2017, 0, `2017`)) %&gt;%
    mutate(`2018` = ifelse(as.numeric(`Start Year`) &gt; 2018, 0, `2018`)) 
  </code></pre>
  
  <p>I need to repeat this for multiple years but am unsure how to reference the columns named <code>2017</code>, <code>2018</code> etc. in a loop. Thanks in advance.</p>