title: How to round up to the nearest 10 (or 100 or X)?
body: <p>I am writing a function to plot data. I would like to specify a nice round number for the y-axis <code>max</code> that is greater than the max of the dataset.</p>
  
  <p>Specifically, I would like a function <code>foo</code> that performs the following:</p>
  
  <pre><code>foo(4) == 5
  foo(6.1) == 10 #maybe 7 would be better
  foo(30.1) == 40
  foo(100.1) == 110 
  </code></pre>
  
  <p>I have gotten as far as</p>
  
  <pre><code>foo &lt;- function(x) ceiling(max(x)/10)*10
  </code></pre>
  
  <p>for rounding to the nearest 10, but this does not work for arbitrary rounding intervals.</p>
  
  <p>Is there a better way to do this in R?</p>