format(x, ...)format.default(x, trim = FALSE, digits = NULL, nsmall = 0L, justify = c("left", "right", "centre", "none"), width = NULL, na.encode = TRUE, scientific = NA, big.mark = "", big.interval = 3L, small.mark = "", small.interval = 5L, decimal.mark = ".", zero.print = NULL, drop0trailing = FALSE, ...)
format.factor(x, ...)
format.data.frame(x, ..., justify = "none")
x | an object of a class that has a method for format, or an atomic object. Missing values (NA) are allowed. |
trim | a logical flag. If FALSE (the default), the formatted numbers have the same length. Note that this flag does not affect formatting of character strings (see "justify"). |
digits | the maximum number of (significant) digits to use. |
nsmall | the minimum number of digits to appear to the right of the decimal. |
justify | a character string giving the justification of character strings relative to each other. The choices are "none", "left", "right" and "centre". Only the first letter needs to be given. Note that this argument does not affect formatting of numbers (see "trim"). |
width | the minimum width of the formatted strings. |
na.encode | a logical flag: if FALSE, character NAs are kept as NA. If TRUE, characters NAs are encoded as the string "NA". |
scientific | a logical flag: if TRUE, numbers are always formatted using scientific notation. If FALSE, numbers are never formatted using scientific notation. If NA, a heuristic is used to determine whether numbers are represented in scientific notation. |
big.mark | the mark with which to group the digits to the left of the decimal. |
big.interval | the number of digits in a group to the left of the decimal. |
small.mark | the character used to group digits to the right of the decimal. |
small.interval | the number of digits in a group to the right of the decimal. |
decimal.mark | the character to put at the decimal place (between the ones place and the one-tenths place). |
zero.print | a logical flag. If FALSE, any item in x that is zero prints as a space. A character string or NULL is allowed. |
drop0trailing | a logical flag. If TRUE, indicates any trailing zero should be removed. |
format(2^seq(10)) # [1] " 2" " 4" " 8" " 16" " 32" # [6] " 64" " 128" " 256" " 512" "1024"