format(x, ...) format.default(x, trim=FALSE, digits = .Options$digits)
x
| any R object (conceptually); typically numeric. |
trim
|
logical; if TRUE , leading blanks are trimmed off the
strings.
|
digits
|
how many significant digits are to be used for
numeric x .
|
print
).
The trimming with trim = TRUE
is useful when the strings are to
be used for plot axis annotation.
The function formatC
provides a rather more flexible
formatting facility for numbers.
formatC
, paste
, as.character
.
format(1:10) for(i in c(1:5,10,15:17,20)) cat(i,":\t",format(pi,digits=i),"\n")