powered by
n.code convert “round integers” to short character strings. This is useful to build up variable names in simulations, e.g.
n.code
code2n is the inverse function of n.code().
code2n
n.code()
n.code(n, ndig = 1, dec.codes = c("", "d", "c", "k")) code2n(ncod, ndig = 1, dec.codes = c("", "d", "c", "k"))
n.code(n) returns a character vector of the same length as n.
n.code(n)
character
n
code2n(ncod) returns a integer vector of the same length as ncod.
code2n(ncod)
integer
ncod
Usually, code2n(n.code(n)) == n.
code2n(n.code(n)) == n
integer vector.
character vector, typically resulting from n.code.
integer giving number of digits before the coding character.
character code for 1, 10, 100, 1000 (etc).
Martin Maechler
n10 <- c(10,20,90, 100,500, 2000,10000) (c10 <- n.code(n10))#-> "1d" "2d" "9d" "1c" .. stopifnot(code2n(c10) == n10)
Run the code above in your browser using DataLab