title: Rounding numbers to nearest 10 in R
body: <p>Now, there has been some very similar questions on SO about rounding and significance, but non solves my issue. Here it is:</p>
  
  <p>How to round randomly occurring numbers like these: </p>
  
  <pre><code>data &lt;- c(152.335, 39.431, 21.894)
  </code></pre>
  
  <p>I would like to have them rounded like this:</p>
  
  <pre><code>c(150,40,20)
  </code></pre>
  
  <p>I have tried:</p>
  
  <pre><code>print(formatC(signif(data,digits=2), digits=2,format="f"))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[1] "150.00" "39.00"  "22.00"
  </code></pre>
  
  <p>The above command requires me to change the <code>digits=</code> to 1 or 2 in order to obtain the desired outcome. But, I would like a global - fit for all command. Thanks. </p>