Learn R Programming

gmp (version 0.7-5)

formatN: Format Numbers Keeping Classes Distinguishable

Description

Format (generalized) numbers in a way that their classes are distinguishable. Contrary to format() which uses a common format for all elements of x, here, each entry is formatted individually.

Usage

formatN(x, ...)
# S3 method for default
formatN(x, ...)
# S3 method for integer
formatN(x, ...)
# S3 method for double
formatN(x, ...)
# S3 method for bigz
formatN(x, ...)
# S3 method for bigq
formatN(x, ...)

Value

a character vector of the same length as x, each entry a representation of the corresponding entry in x.

Arguments

x

any R object, typically “number-like”.

...

potentially further arguments passed to methods.

Author

Martin Maechler

See Also

format, including its (sophisticated) default method; as.character.

Examples

Run this code
## Note that each class is uniquely recognizable from its output:
formatN(    -2:5)# integer
formatN(0 + -2:5)# double precision
formatN(as.bigz(-2:5))
formatN(as.bigq(-2:5, 4))

Run the code above in your browser using DataLab