num_order_to_word: Convert a vector of numbers to large-number word...

View source: R/math_funcs.R

num_order_to_wordR Documentation

Convert a vector of numbers to large-number word representation

Description

Converts a vector of numbers to a character string approximation using the "short scale" version of large number names. e.g. 312e6 returns as '300 million.' Simultaneously returns a numeric representation of the approximation.

Usage

num_order_to_word(x, lookup = NULL, nsmall = 0)

Arguments

x

A vector of numbers to convert.

lookup

Optional. A data frame specifying numeric exponents as 'expon' and corresponding names as 'word'. e.g. lookup = data.frame(expon = c(3, 0, -3), word = c("thousands", "", "thousandths"))

nsmall

Optional. An integer number of digits to include to the right of the the leading digit

Value

A data frame containing the originally-supplied vector, the short scale version, and its string representation

Examples

# Simplest example
num_order_to_word(1340)
# Using a variable
x <- exp(1)^20
num_order_to_word(x)
num_order_to_word(x, nsmall = 1)
x <- exp(1)^-10
num_order_to_word(x)
## Not run: 
x <- 1:4
num_order_to_word(x)

## End(Not run)

tomhopper/numbr documentation built on Nov. 5, 2022, 11:35 p.m.