Lookup an SI prefix by name, by exponent (power of 10), or by value. For exponents or values, the best SI prefix is returned.
si_prefix(x) # S3 method for character si_prefix(x) # S3 method for integer si_prefix(x) # S3 method for numeric si_prefix(x)
A named character vector where values are the SI prefix exponents
and names are the SI prefix names, from SI_PREFIXES
.
character
: x
are the names of the prefixes. The prefix
mu can be referred to with its unicode value, "\u03BC"
, or "mu"
.
Empty or missing values map to no strings. Invalid values return NA
.
integer
: x
are the exponents of the SI prefixes,
\(-24, -21, ..., -3, 0, 3, ..., 21, 24\).
numeric
: x
are numeric values.
# lookup by name si_prefix(c("k", "T", "mu", "\u03BC", "", NA))#> k T μ μ #> 3 12 -6 -6 0 0# lookup by exponent with integers si_prefix(c(-2L, -1L, 0L, 5L))#> m m k #> -3 -3 0 3# lookup by value with numeric vectors si_prefix(c(-1100, 5, 1.5e8))#> k M #> 3 0 6