{base}R Documentation

format(.) Information


Information is returned on how format(x, digits, nsmall) would be formatted.

Usage, digits = NULL, nsmall = 0)


x an atomic vector; a potential argument of format(x, ...).
digits how many significant digits are to be used for numeric and complex x. The default, NULL, uses getOption(digits).
nsmall (see format(..., nsmall)).


An integer vector of length 1, 3 or 6, say r.
For logical, integer and character vectors a single element, the width which would be used by format if width = NULL.
For numeric vectors:

r[1] width (in characters) used by format(x)
r[2] number of digits after decimal point.
r[3] in 0:2; if >=1, exponential representation would be used, with exponent length of r[3]+1.

For a complex vector the first three elements refer to the real parts, and there are three further elements corresponding to the imaginary parts.

See Also

format, formatC.


dd <- options("digits") ; options(digits = 7) #-- for the following   # 3 0 0    # 8 6 0   # 5 0 1 - exponential "1e+08" # 6 0 2 - exponential "1e+222"

x <- pi*10^c(-10,-2,0:2,8,20)
names(x) <- formatC(x,w=1,dig=3,format="g")

## using at least 8 digits right of "."
t(sapply(x,, nsmall = 8))

# Reset old options:

[Package base version 2.5.0 Index]