title: How to round numbers according to a fixed interval
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8664976/r-round-to-nearest-5-or-1">R round to nearest .5 or .1</a><br>
    <a href="https://stackoverflow.com/questions/9502895/how-do-i-round-to-1-1-5-2-etc-instead-of-1-2-or-1-1-1-2-1-3-in-r">How do I round to 1, 1.5, 2 etc instead of 1, 2 or 1.1, 1.2, 1.3 in R?</a>  </p>
  </blockquote>
  
  
  
  <p>if I want to round a number with some digits after comma</p>
  
  <pre><code>a &lt;- 2.1357
  </code></pre>
  
  <p>I can use</p>
  
  <pre><code>round(a, 1)
  </code></pre>
  
  <p>to obtain 2.1 as result.</p>
  
  <p>Now let I have an array of numbers like</p>
  
  <pre><code>b &lt;- rnorm(n = 10, mean = .5, sd = .1)
  &gt; b
  [1] 0.5554950 0.4527671 0.5217543 0.6137458 0.6023219 0.7045009 0.5140363 0.5312920
  [9] 0.5841152 0.4492901
  </code></pre>
  
  <p>If I want to round those numbers in order to <strong>make them multiples of 0.1</strong>, it's enough to input</p>
  
  <pre><code>round(b, 1)
  </code></pre>
  
  <p>Now my question: what if I would like to round them in order to make the multiples of... <strong>0.2</strong>? Or <strong>0.3</strong>? Or <strong>0.25</strong>... an so on?</p>
  
  <p>Thanks,</p>