formatcomma: Print numbers with commas and 0-2 decimal places

View source: R/formatcomma.R

formatcommaR Documentation

Print numbers with commas and 0-2 decimal places

Description

Wrapper for format() making it easier to use with my typical settings

Usage

formatcomma(x, big.m = ",", nsmall = 2, drop0trailing = FALSE, ...)

Arguments

x

Numeric vector

big.m

Default is a comma at every three digits (1,000,000)

nsmall

Default is 2 digits after the decimal (3.14)

drop0trailing

Default is FALSE, which means zeroes after the last nonzero digit in the decimal portion are still shown (TRUE would mean 1.2 is shown, not 1.20)

...

other parameters passed to format()

Value

Same as format() but with some preselected defaults

See Also

format()

Examples

 cbind(mynum=formatcomma(c(1452345, 1.2, 4234.12345)))
 cbind(mynum=formatcomma(c(1452345, 1.2, 4234.12345), drop0trailing=FALSE))

ejanalysis/analyze.stuff documentation built on April 2, 2024, 10:10 a.m.