title: r: conditionally replace values in a subset of columns
body: <p>I have a dataframe like so:</p>
  
  <pre><code>sport   contract start contract end visits spends purchases
  basket   2013-10-01     2014-10-01   12      14      23
  basket   2014-02-12     2015-03-03   23      11      7
  football 2015-02-12     2016-03-03   23      11      7
  basket   2016-07-17     2013-09-09   12       7      13
  </code></pre>
  
  <p>I would like to conditionally replace the columns [4:6] with NAs, based on the variables "sport" and "contract start".
  So for instance:</p>
  
  <pre><code>i1 &lt;- which(df$sport =="basket" &amp; df$contract_start&gt;="2014-01-01")
  </code></pre>
  
  <p>will index all the rows in which my conditions are met.
  Is there an easy piece of code to add to the above, that will replace df[4:6] with NAs given the above conditions?
  I would like to end up with something like that:</p>
  
  <pre><code>sport   contract start contract end visits spends purchases
  basket   2013-10-01     2014-10-01   12      14      23
  basket   2014-02-12     2015-03-03   NA      NA      NA
  football 2015-02-12     2016-03-03   23      11      7
  basket   2016-07-17     2013-09-09   NA      NA      NA
  </code></pre>
  
  <p>Thanks!
  A.</p>