n.code | R Documentation |
n.code
convert “round integers” to short character strings.
This is useful to build up variable names in simulations, e.g.
code2n
is the inverse function of n.code()
.
n.code(n, ndig = 1, dec.codes = c("", "d", "c", "k"))
code2n(ncod, ndig = 1, dec.codes = c("", "d", "c", "k"))
n |
integer vector. |
ncod |
character vector, typically resulting from
|
ndig |
integer giving number of digits before the coding character. |
dec.codes |
character code for 1, 10, 100, 1000 (etc). |
n.code(n)
returns a character
vector of the same
length as n
.
code2n(ncod)
returns a integer
vector of the same
length as ncod
.
Usually, code2n(n.code(n)) == n
.
Martin Maechler
n10 <- c(10,20,90, 100,500, 2000,10000)
(c10 <- n.code(n10))#-> "1d" "2d" "9d" "1c" ..
stopifnot(code2n(c10) == n10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.