format {base} | R Documentation |
Encode in a Common Format
Description
These functions convert their first argument to a vector (or array) of
character strings which have a common format (as is done by
print
).
The trimming with trim = TRUE
is useful when the strings are to
be used for plot axis
annotation.
format.pval
is mainly an auxiliary function for
print.summary.lm
etc., does separate formatting for
fixed, floating point and very small values (those < eps
).
The function formatC
provides a rather more flexible
formatting facility for numbers, does not provide a common format
for several numbers, however.
Usage
format(x, ...)
format.default(x, trim=FALSE, digits = .Options$digits)
format.pval(x, digits= max(1,.Options$digits-2), eps = .Machine$double.eps)
Arguments
x |
any R object (conceptually); typically numeric. |
trim |
logical; if |
digits |
how many significant digits are to be used for
|
See Also
formatC
, paste
, as.character
.
Examples
format(1:10)
p _ c(47,13,2,.1,.023,.0045, 1e-100)/1000
format.pval(p)
format.pval(p / 0.9)
format.pval(p / 0.9, dig=3)