dot-round: Safe Rounding Function

.roundR Documentation

Safe Rounding Function

Description

Rounds numbers to the specified number of decimal places. Unlike round, it handles NULL inputs gracefully by returning NULL and optionally prints a warning.

Usage

.round(x, digits = 0, verbose = FALSE)

Arguments

x

Numeric vector or NULL.

digits

Integer indicating the number of decimal places to round to.

verbose

Logical; if TRUE, prints a warning when x is NULL.

Value

Rounded number or NULL if input is NULL.

Examples

roundSafe(3.14159, digits = 2)
roundSafe(NULL) # returns NULL with a warning

jn-goe/gruffi documentation built on Nov. 7, 2024, 10:38 p.m.