Package 'roundR'

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

Help Index


Round to the nearest integer

Description

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().

Usage

round_to_integer(x)

Arguments

x

A numeric element or vector to round to the nearest integer

Value

An integer element or vector

Author(s)

Gerko Vink [email protected] and Hanne Oberman [email protected]

Examples

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()