comma_format: Comma formatter: format number with commas separating...

Description Usage Arguments Value Examples

View source: R/formatter.r

Description

Comma formatter: format number with commas separating thousands.

Usage

1
2
3

Arguments

...

other arguments passed on to format

x

a numeric vector to format

Value

a function with single parameter x, a numeric vector, that returns a character vector

Examples

1
2
3
4
5
6
7
8
9
comma_format()(c(1, 1e3, 2000, 1e6))
comma_format(digits = 9)(c(1, 1e3, 2000, 1e6))
comma(c(1, 1e3, 2000, 1e6))

# If you're European you can switch . and , with the more general
# format_format
point <- format_format(big.mark = ".", decimal.mark = ",", scientific = FALSE)
point(c(1, 1e3, 2000, 1e6))
point(c(1, 1.021, 1000.01))

Example output

[1] "1"         "1,000"     "2,000"     "1,000,000"
[1] "1"         "1,000"     "2,000"     "1,000,000"
[1] "1"         "1,000"     "2,000"     "1,000,000"
[1] "1"         "1.000"     "2.000"     "1.000.000"
[1] "1,000"     "1,021"     "1.000,010"

scales documentation built on Aug. 24, 2017, 5:22 p.m.