EVOLUTION-MANAGER
Edit File: round_half_up.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Round a numeric vector; halves will be rounded up, ala...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for round_half_up {janitor}"><tr><td>round_half_up {janitor}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Round a numeric vector; halves will be rounded up, ala Microsoft Excel.</h2> <h3>Description</h3> <p>In base R <code>round()</code>, halves are rounded to even, e.g., 12.5 and 11.5 are both rounded to 12. This function rounds 12.5 to 13 (assuming <code>digits = 0</code>). Negative halves are rounded away from zero, e.g., -0.5 is rounded to -1. </p> <p>This may skew subsequent statistical analysis of the data, but may be desirable in certain contexts. This function is implemented exactly from <a href="https://stackoverflow.com/a/12688836">https://stackoverflow.com/a/12688836</a>; see that question and comments for discussion of this issue. </p> <h3>Usage</h3> <pre> round_half_up(x, digits = 0) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric vector to round.</p> </td></tr> <tr valign="top"><td><code>digits</code></td> <td> <p>how many digits should be displayed after the decimal point?</p> </td></tr> </table> <h3>Examples</h3> <pre> round_half_up(12.5) round_half_up(1.125, 2) round_half_up(1.125, 1) round_half_up(-0.5, 0) # negatives get rounded away from zero </pre> <hr /><div style="text-align: center;">[Package <em>janitor</em> version 2.1.0 <a href="00Index.html">Index</a>]</div> </body></html>