title: Assign value to specific range
body: <p>I have an easy question to figure out:  </p>
  
  <pre><code>value
  1000
  2500
  5080
  10009
  </code></pre>
  
  <p>I want to specify <code>value</code> to an interval:  </p>
  
  <pre><code>value    Range
  1000     0-1000
  2500     1001-5000
  5080     5001-10000
  10009    10001-20000
  </code></pre>
  
  <p>I try this:  </p>
  
  <pre><code>dt[, Range := ifelse(value &lt; 1001, "0-1000", ifelse(1000 &lt; value &lt; 5001, "1001-5000", ifelse(5000 &lt; value &lt; 10001, "5001-10000", "10001-20000")))
  </code></pre>
  
  <p>However, I got <code>Error: unexpected '&lt;' in "dt[, Range := ifelse(value &lt; 1001, "0-1000", ifelse(1000 &lt; value &lt;"</code>  </p>
  
  <p>Any help?</p>
  
  <p>EDIT:</p>
  
  <p>This question is not asking for the best way to convert a continuous variable to a factor. It is asking for debugging help with the reproducible example:</p>
  
  <pre><code>library(data.table)
  dt &lt;- data.table(value = c(1000, 2500, 5080, 10009))
  dt[, Range := ifelse(value &lt; 1001, "0-1000", ifelse(1000 &lt; value &lt; 5001, "1001-5000", ifelse(5000 &lt; value &lt; 10001, "5001-10000", "10001-20000")))
  # produces the error above
  </code></pre>