comma: Numeric vector with thousands separators

Description Usage Arguments Examples

View source: R/formats.R

Description

Numeric vector with thousands separators

Usage

1
2
3
4
5
6
7
comma(x, digits, format = "f", big.mark = ",", ...)

## Default S3 method:
comma(x, digits = 2L, format = "f", big.mark = ",", ...)

## S3 method for class 'character'
comma(x, digits = max(get_digits(x)), format = "f", big.mark = ",", ...)

Arguments

x

a numeric vector.

digits

an integer to indicate the number of digits of the percentage string.

format

format type passed to formatC.

big.mark

thousands separator

...

additional parameters passed to formattable.

Examples

1
2
3
4
comma(1000000)
comma(c(1250000, 225000))
comma(c(1250000, 225000), format = "d")
comma("123,345.123")

Example output

[1] 1,000,000.00
[1] 1,250,000.00 225,000.00  
[1] 1,250,000 225,000  
[1] 123,345.123

formattable documentation built on Jan. 13, 2021, 7:17 a.m.