Learn R Programming

psychmeta (version 2.6.5)

round2char: 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)

Value

A vector of rounded numbers converted to characters

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).

Examples

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

Run the code above in your browser using DataLab