numeric_label: Numeric labels for internal use and special cases

Description Usage Arguments Value Author(s) See Also Examples

Description

Low level function for generating all other types of numeric labels. The end-user should primarily use functions listed in quantity_label, whereas this function is intended for internal use and special cases. If you find that you are regularly using numeric_label for a case not covered by the end-user functions, please file an issue on GitHub for adding it.

Usage

1
2
numeric_label(x, prefix = NULL, unit = "", unit_position = c("after",
  "before"), digits = 3, space = TRUE)

Arguments

x

Numeric values.

prefix

A data frame containing prefix symbols and powers, see prefix.

unit

Unit symbol.

unit_position

Whether to put the unit before or after the numerical value.

digits

Number of significant digits, sent to signif.

space

Whether to put a space between numeric value and unit.

Value

Character vector.

Author(s)

Christofer Bäcklin

See Also

quantity_label, prefix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Physical quantities
n <- 12
x <- 10^rnorm(n, sd = 6) * ifelse(runif(n) < .5, -1, 1)

data.frame(
  x = x,
  label = quantity_label(x, unit = "g")
)

# Currencies
x <- round(10^c(rgamma(n/2, 3, 1) - 2, rgamma(n/2, 5, 1)), digits = 2) * ifelse(runif(n) < .5, -1, 1)

data.frame(
  x = x,
  EUR = currency_label(x, prefix = TRUE, currency = "EUR"),
  USD = currency_label(x, prefix = TRUE, currency = "USD"),
  GBP = currency_label(x, prefix = TRUE, currency = "GBP"),
  SEK = currency_label(x, prefix = TRUE, currency = "SEK")
)

backlin/treesmapstheorems documentation built on May 11, 2019, 5:23 p.m.