Skip to contents

By default the numeric vectors are first rounded to three significant figures. Then scales::comma is only applied to values greater than or equal to 1000 to ensure that labels are permitted to have different numbers of decimal places.

Usage

comma_signif(x, digits = 3, ...)

Arguments

x

A numeric vector to format.

digits

A whole number specifying the number of significant figures.

...

Additional arguments passed to scales::comma.

Value

A character vector.

Examples

comma_signif(c(0.1, 1, 10, 1000))
#> [1] "0.1"   "1"     "10"    "1,000"
scales::comma(c(0.1, 1, 10, 1000))
#> [1] "0.1"     "1.0"     "10.0"    "1,000.0"