title: Create flag indicating if year variable is in the range of start:end variables in data.table
body: <p>I have a data.table with 3 date variables: <code>year</code>, <code>start</code>, <code>end</code>. </p>
  
  <pre><code>test &lt;- data.table(year=2001:2003,start=c(2003,2002,2000),end=c(2003,2004,2002),x_desired=c(F,T,F))
  </code></pre>
  
  <p>O want to create a new variable <code>x</code>, indicating, for each row, if <code>year</code> is in the range defined by <code>start</code> and <code>end</code>. The correct desired result is in the variable <code>x_desired</code>. </p>
  
  <p>I imagined this could be done with:</p>
  
  <pre><code>test[,x:=(year %in% start:end)]
  </code></pre>
  
  <p>but the result is clearly not correct. I wanted the ranges to be defined row-by-row, but don't know how to express that.</p>