alpha2int                package:VLMC                R Documentation

'_S_i_n_g_l_e _C_h_a_r_a_c_t_e_r' <-> _I_n_t_e_g_e_r _C_o_n_v_e_r_s_i_o_n _f_o_r _D_i_s_c_r_e_t_e _D_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     Simple conversion functions for discrete data (e.g., time series),
     between '0:k' integers and _single_ letter characters.

_U_s_a_g_e:

     alpha2int(x, alpha)
     int2alpha(i, alpha)

_A_r_g_u_m_e_n_t_s:

       x: character vector of single letters.

   alpha: the alphabet, as one character string.

       i: integer vector of numbers in '0:k'.

_V_a_l_u_e:

     'alpha2int(x,*)' returns an 'integer' vector of the same length as
     'x', consisting of values from '0:k' where 'k + 1' is the length
     of the alphabet, 'nchar(alpha)'.

     'int2alpha(i,*)' returns a vector of _single letter_ 'character'
     of the same length as 'i'.

_S_e_e _A_l_s_o:

     'vlmc', and 'int2char()' and its inverse, 'char2int()', both
     working with multi-character strings instead of vectors of single
     characters; further, 'alphabet'.

_E_x_a_m_p_l_e_s:

     alphabet <- "abcdefghijk"
     (ch <- sample(letters[1:10], 30, replace = TRUE))
     (ic <- alpha2int(ch, alphabet))
     stopifnot(int2alpha(ic, alphabet) == ch)

