fmt_new: Format numbers

Description Usage Arguments Value Examples

Description

The function fmt_new creates a function to format numbers using a given locale and spec. The function fmt formats numbers, and is a convenience function for fmt_new(...)(x).

Usage

1
2
3
fmt_new(spec = NULL, locale = NULL, si_prefix = NULL)

fmt(x, spec = NULL, locale = NULL, ...)

Arguments

spec

A fmt_spec object, or a string coerced to a fmt_spec object using as_fmt_spec, or a list of arguments passed to fmt_spec.

locale

A fmt_locale object.

si_prefix

If non-NULL, then use an SI prefix to format x. If TRUE, then use precision_prefix to automatically determine the SI prefix to use. Otherwise, it can be any of the valid arguments for si_prefix: a string with the prefix name, an integer with the SI prefix exponent, or a numeric value. Unlike the "s" format type, this applies the same prefix to all values in x, rather than determining the SI-prefix on a value by value basis. Additionally, a non-NULL si implies a "f" format type, in which precision represents the number of digits past the decimal point.

x

A numeric or integer vector

...

Arguments passed to fmt_new.

Value

fmt_new returns a function with a single argument. fmt returns a function of the same length as x of formatted numbers.

Examples

1
fmt(c(0.00042, 0.0042), spec = ",.0", si_prefix = 1e-6)

jrnold/fivemat documentation built on May 20, 2019, 1 a.m.