Skip to contents

Function round rounds - by default - the number 1.5 to integer 2 and the number 2.5 also to integer 2. The reason for this behaviour is the IEC 60559 standard where a 5 is expected to be rounded to the even digit. This function provides an integer rounding alternative to round.

Usage

rounder(x)

Arguments

x

A numeric element or vector to round to the nearest integer

Value

An integer element or vector

Author

Gerko Vink g.vink@uu.nl and Hanne Oberman h.i.oberman@uu.nl

Examples

library(magrittr)
# rounds weirdly
c(0.5, 1.5, 2.5, 3.5) %>% round()
#> [1] 0 2 2 4
# rounds correctly
c(0.5, 1.5, 2.5, 3.5) %>% rounder()
#> [1] 1 2 3 4