letter              package:Biostrings              R Documentation

_S_u_b_s_e_t_t_i_n_g _a _s_t_r_i_n_g

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

     Extract a substring from a string by picking up individual letters
     by their position.

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

       letter(x, i)

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

       x: A character vector, or an XString, XStringViews or
          MaskedXString object. 

       i: An integer vector with no NAs. 

_D_e_t_a_i_l_s:

     Unlike with the 'substr' or 'substring' functions, 'i' must
     contain valid positions.

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

     A character vector of length 1 when 'x' is an XString or
     MaskedXString object (the masks are ignored for the latter).

     A character vector of the same length as 'x' when 'x' is a
     character vector or an XStringViews object.

     Note that, because 'i' must contain valid positions, all non-NA
     elements in the result are guaranted to have exactly 'length(i)'
     characters.

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

     'subXString', XString-class, XStringViews-class,
     MaskedXString-class

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

       x <- c("abcd", "ABC")
       i <- c(3, 1, 1, 2, 1)

       ## With a character vector
       letter(x[1], 3:1)
       letter(x, 3)
       letter(x, i)
       #letter(x, 4)             # Error!

       ## With a BString object
       letter(BString(x[1]), i)  # character vector
       BString(x[1])[i]          # BString object

       ## With an XStringViews object
       x2 <- XStringViews(x, "BString")
       letter(x2, i)

