round2: Round numbers to specified number of digits This function is...

View source: R/round2.R

round2R Documentation

Round numbers to specified number of digits This function is a drop-in replacement for base::round()

Description

Unlike base::round(), it does NOT follow the IEC 60559 standard by rounding numbers ending in .5 to the even digit. Instead, 0.5 is rounded up.

Usage

round2(x, digits = 0)

Arguments

x

a numeric vector of numbers to round

digits

integer indicating the number of decimal places to which x should be rounded.

Source

https://stackoverflow.com/questions/12688717/round-up-from-5

Examples

# This gives '2'
base::round(2.5)

# This gives 3
round2(2.5)

djpr-data/djprshiny documentation built on May 14, 2023, 1:15 p.m.