si_prefix: Lookup SI prefix

Description Usage Arguments Value Methods (by class) Examples

Description

Lookup an SI prefix by name, by exponent (power of 10), or by value. For exponents or values, the best SI prefix is returned.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
si_prefix(x)

## S3 method for class 'character'
si_prefix(x)

## S3 method for class 'integer'
si_prefix(x)

## S3 method for class 'numeric'
si_prefix(x)

Arguments

x

A vector

Value

A named character vector where values are the SI prefix exponents and names are the SI prefix names, from SI_PREFIXES.

Methods (by class)

Examples

1
2
3
4
5
6
# lookup by name
si_prefix(c("k", "T", "mu", "\u03BC", "", NA))
# lookup by exponent with integers
si_prefix(c(-2L, -1L, 0L, 5L))
# lookup by value with numeric vectors
si_prefix(c(-1100, 5, 1.5e8))

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