| Title: | Round Numeric Values to the Nearest Integer |
|---|---|
| Description: | By default, R rounds numeric values to even integers, following the IEC 60559 standard. This package offers alternative functionality to round to the closest integer. |
| Authors: | Hanne Oberman [aut, cre], Gerko Vink [aut] |
| Maintainer: | Hanne Oberman <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-16 07:58:21 UTC |
| Source: | https://github.com/hanneoberman/roundR |
The base::round() function rounds the number 1.5 to 2 and the number
2.5 also to 2, because of the IEC 60559 standard. This function provides
an integer rounding alternative to base::round().
round_to_integer(x)round_to_integer(x)
x |
A numeric element or vector to round to the nearest integer |
An integer element or vector
Gerko Vink [email protected] and Hanne Oberman [email protected]
library(dplyr) # unexpected rounding c(0.5, 1.5, 2.5, 3.5) |> round() # rounding to nearest integer c(0.5, 1.5, 2.5, 3.5) |> round_to_integer()library(dplyr) # unexpected rounding c(0.5, 1.5, 2.5, 3.5) |> round() # rounding to nearest integer c(0.5, 1.5, 2.5, 3.5) |> round_to_integer()