title: R (data.table) group data by custom range (for example, -18, 18-25, ..., 65+)
body: <p>I can't find a solution in R (using data.table) to group data by a custom range (for example, -18, 18-25, ..., 65+) not by a single value.</p>
  
  <p>What I'm using right now:</p>
  
  <pre><code>DT[,list(M_Savings=mean(Savings), M_Term=mean(Term)), by=Age] [order (Age)]
  </code></pre>
  
  <p>This gives me the following result:</p>
  
  <pre><code>    Age     M_Savings   M_Term
  1:  18      6500        5.5 
  2:  19      7000        6.2 
  3:  20      7200        5.8
  ...
  50: 68      4000        4.2 
  </code></pre>
  
  <p>Desirable result:</p>
  
  <pre><code>    Age     M_Savings   M_Term
  1:  18-25   7450        5.5 
  2:  25-30   8320        6.2 
  ...
  50: 65+     3862        4.3 
  </code></pre>
  
  <p>I Hope that my explanation is clear enough.
  Will appreciate any kind of help.</p>