round2char: Round numeric values to an exact number of digits and return...

View source: R/developer_utils.R

round2charR Documentation

Round numeric values to an exact number of digits and return as a character

Description

Round numeric values to an exact number of digits and return as a character

Usage

round2char(x, digits = 3, na_replace = "", omit_leading_zero = FALSE)

Arguments

x

Numeric values

digits

Number of digits to which result should be rounded

na_replace

Scalar value: Character with which NA values should be replaced

omit_leading_zero

Logical scalar determining whether to omit leading zeros (TRUE) or retain them (FALSE; default).

Value

A vector of rounded numbers converted to characters

Examples

# round2char(x = .50000005)
# round2char(x = NA, na_replace = "---")

psychmeta/psychmeta documentation built on Feb. 12, 2024, 1:21 a.m.