round2: Round up from .5

Description Usage Arguments Details Examples

View source: R/webex_fns.R

Description

Round up from .5

Usage

1
round2(x, digits = 0)

Arguments

x

A numeric string (or number that can be converted to a string).

digits

Integer indicating the number of decimal places ('round') or significant digits ('signif') to be used.

Details

Implements rounding using the "round up from .5" rule, which is more conventional than the "round to even" rule implemented by R's built-in round function. This implementation was taken from https://stackoverflow.com/a/12688836.

Examples

1
2
3
4
round2(c(2, 2.5))

# compare to:
round(c(2, 2.5))

webex documentation built on June 10, 2021, 9:09 a.m.