title: R - round to nearest half
body: <p>I have the following data:</p>
  
  <pre><code>&gt; vec
   [1] 0.0 0.5 1.0 1.4 1.9 2.4 3.1 3.6 4.1 4.6 5.0 5.5 6.0 6.5 7.0 7.4 7.9 8.4 9.1 
  </code></pre>
  
  <p>which I need to round to the nearest .5. </p>
  
  <p>Let me be more specific: 1.4 becomes 1.5, and 1.9 becomes 2.0. Also, 2.4 becomes 2.5, and 3.1 becomes 3.0. And so on. The vector I expect is:</p>
  
  <pre><code>&gt; vec
   [1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Many thanks.</p>