rounded: rounded

View source: R/rounding.R

roundedR Documentation

rounded

Description

Rounds positive numbers to integers (i.e., zero decimal places).

Usage

rounded(x)

Arguments

x

A numeric vector

Details

The base R round function "rounds to even" when rounding off a 5 (e.g., 0.5 rounds to 0 and 1.5 rounds to 2). To ensure that 0.5 is rounded up, rounded adds 0.5 to the input and truncates. Note that this function only works for positive numbers.

Examples

rounded(.5 + 0:4) # 1  2  3  4  5
## different from IEEE / IEC rounding: 0  2  2  4  4

bcgov/WEStblr documentation built on Dec. 2, 2022, 10:53 a.m.