texNum: Convert number to English prose

Description Usage Arguments Value Examples

Description

This takes an arbitrary numbers and prints like a human would transcribe it. Designed to be used within \Sexpr.

Usage

1
2
texNum(number, sig.figs = 3L, dollar = FALSE, pre.phrase = NULL,
  .suffix = NULL)

Arguments

number

A single numeric vector.

sig.figs

Significant figures to be displayed

dollar

Logical, should a LaTeX dollar sign (\$) be prefixed.

pre.phrase

A length 2 character vector to insert a phrase before the number. The first element is the phrase to be used if the output rounds up before printing (i.e. the original number is smaller than the number printed); the second is the phrase to be used if the number rounds down. The default is NULL, i.e. no phrase inserted. If either string has a trailing tilde (e.g. "almost~"), the tilde separates the number and the phrase (as a LaTeX control sequence).

.suffix

Either NULL for an automatic suffix based on the magnitude of the number, or one of million, billion, trillion for a fixed suffix.

Value

A character string representing the number as appropriate for English prose.

Examples

1
2
3
texNum(500e3)
texNum(500e3 - 1, pre.phrase = c("almost", "over"))
texNum(500e6)

HughParsonage/grattanCharts documentation built on May 8, 2019, 10:52 a.m.