title: Replace a numerical value by NA based on conditions from other columns
body: <p>This is related to a prior question which can be found in:</p>
  
  <p><a href="https://stackoverflow.com/questions/15768417/">Replace a numerical value by NA based on conditions from other columns:</a></p>
  
  <p>Below is the data:</p>
  
  <pre><code>DT &lt;- data.table(a = sample(c("C","M","Y","K"),  100, rep=TRUE),
                     b = sample(c("A","S"),  100, rep=TRUE),
                     f = round(rnorm(n=100, mean=.90, sd=.08),digits = 2) ); DT
  </code></pre>
  
  <p>I would like an elegant and succinct re-write for the following functions:</p>
  
  <pre><code>`%between%` &lt;- function(x, vals) { x &gt;= vals[1] &amp; x &lt;= vals[2]}
  `%nbetween%` &lt;- Negate(`%between%`)
  </code></pre>
  
  <p>and the following script to replace a certain values that meet certain conditions with NA </p>
  
  <pre><code>DT[a == "C" &amp; b %in% c("A", "S") &amp; f %nbetween% c(.85, .95), f := NA]
  DT[a == "M" &amp; b %in% c("A", "S") &amp; f %nbetween% c(.85, .95), f := NA]
  DT[a == "Y" &amp; b %in% c("A", "S") &amp; f %nbetween% c(.80, .90), f := NA]
  DT[a == "K" &amp; b %in% c("A", "S") &amp; f %nbetween% c(.95, 1.10), f := NA]
  </code></pre>