| format {tutoR} | R Documentation |
Format a number for pretty printing - tutoR mask.
format(x, digits=0, width=0, justify="right", ...)
x |
any numeric value. |
digits |
number of digits to appear to the right of the decimal point. |
width |
number of character spaces the number is to be aligned in,
where a width of 0 procuces a number necessarily left justified. |
justify |
should the final character vector be "right"-justified (the default), "left"-justified or "centre" aligned. |
... |
Additional inputs to format.default, called on appropriately. |
The tutoR function, format, masks format from base,
with format.default preserved.
A string with the number in the desired format.
format.default, formatC, paste,
as.character, sprintf, print,
toString, encodeString.
format(1:10, 2)
## use of nsmall
format(13.7)
format.default(13.7, nsmall = 3)
format(c(6.0, 13.1), digits = 2)
format.default(c(6.0, 13.1), digits = 2, nsmall = 1)
## use of scientific
format(2^31-1)
format.default(2^31-1, sci = TRUE)
## a list
z <- list(a=letters[1:3], b=(-pi+0i)^((-2:2)/2), c=c(1,10,100,1000),
d=c("a", "longer", "character", "string"))
format.default(z, digits = 2)
format.default(z, digits = 2, justify = "left", trim = FALSE)