int2char: Character - Integer Conversion

Description Usage Arguments Value See Also Examples

Description

Simple conversion utilities for character to integer conversion and vice versa.

Usage

1
2
int2char(i, alpha)
char2int(x, alpha)

Arguments

i

integer vectors, typically in 0:m when alpha has m + 1 letters.

alpha

character string with several letters, representing the alphabet.

x

character string, typically with letters from alpha.

Value

int2char() gives a string (length 1 character) with as many characters as length(i), by 0-indexing into the alphabet alpha.

char2int() gives an integer vector of length nchar(x) of integer codes according to alpha (starting at 0 !).

See Also

int2alpha() (which is used by int2char) and its inverse, int2alpha(), both working with vectors of single characters instead of multi-character strings.

Examples

1
2
3
4
char2int("vlmc", paste(letters, collapse=""))

int2char(c(0:3, 3:1), "abcd")
int2char(c(1:0,3,3), "abc") # to eat ;-)

Example output

[1] 21 11 12  2
[1] "abcddcb"
[1] "baNANA"

VLMC documentation built on May 1, 2019, 11:32 p.m.

Related to int2char in VLMC...