Format an integer as a string
Arguments
- x
numericvector or matrix- big.mark, trim, scientific
passed to
base::format()but configured with defaults intended for integer values:big.mark=","adds comma between thousands.trim=TRUEto trim excess whitespace.scientific=FALSEto prevent exponential notation.
- forceInteger
logical, default TRUE, whether to roundnumerictointegerprior to callingbase::format().- ...
Additional arguments are ignored.
Details
This function is a quick wrapper function around base::format()
to display integer values as text strings. It will also return a
matrix if the input is a matrix.
See also
Other jam string functions:
asSize(),
breaksByVector(),
fillBlanks(),
gsubOrdered(),
gsubs(),
makeNames(),
nameVector(),
nameVectorN(),
padInteger(),
padString(),
pasteByRow(),
pasteByRowOrdered(),
sizeAsNum(),
tcount(),
ucfirst()
Examples
x <- c(1234, 1234.56, 1234567.89);
## By default, commas are used for big.mark, and decimal values are hidden
formatInt(x);
#> [1] "1,234" "1,235" "1,234,568"
## By default, commas are used for big.mark
formatInt(x, forceInteger=FALSE);
#> [1] "1,234.00" "1,234.56" "1,234,567.89"