lcSuffix               package:Biobase               R Documentation

_C_o_m_p_u_t_e _t_h_e _l_o_n_g_e_s_t _c_o_m_m_o_n _p_r_e_f_i_x _o_r _s_u_f_f_i_x _o_f _a _s_t_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     These functions find the longest common prefix or suffix among the
     strings in a character vector.

_U_s_a_g_e:

     lcPrefix(x, ignore.case=FALSE)
     lcPrefixC(x, ignore.case=FALSE)
     lcSuffix(x, ignore.case=FALSE)

_A_r_g_u_m_e_n_t_s:

       x: a character vector. 

ignore.case: A logical value indicating whether or not to ignore the
          case in making comparisons. 

_D_e_t_a_i_l_s:

     Computing the longest common suffix is helpful for truncating
     names of objects, like microarrays, that often have a common
     suffix, such as .CEL.

     There are some potential problems with the approach used if
     multibyte character encodings are being used.

     'lcPrefixC' is a faster implementation in C.  It only handles
     ascii characters.

_V_a_l_u_e:

     The common prefix or suffix.

_A_u_t_h_o_r(_s):

     R. Gentleman

_S_e_e _A_l_s_o:

     'nchar', 'nchar'

_E_x_a_m_p_l_e_s:

     s1 <- c("ABC.CEL", "DEF.CEL")
     lcSuffix(s1)

     s2 <- c("ABC.123", "ABC.456")
     lcPrefix(s2)

     CHK <- stopifnot

     CHK(".CEL" == lcSuffix(s1))
     CHK("bc" == lcSuffix(c("abc", "333abc", "bc")))
     CHK("c" == lcSuffix(c("c", "abc", "xxxc")))
     CHK("" == lcSuffix(c("c", "abc", "xxx")))

     CHK("ABC." == lcPrefix(s2))
     CHK("ab" == lcPrefix(c("abcd", "abcd123", "ab", "abc", "abc333333")))
     CHK("a" == lcPrefix(c("abcd", "abcd123", "ax")))
     CHK("a" == lcPrefix(c("a", "abcd123", "ax")))
     CHK("" == lcPrefix(c("a", "abc", "xxx")))

     CHK("ab" == lcPrefixC(c("abcd", "abcd123", "ab", "abc", "abc333333")))
     CHK("a" == lcPrefixC(c("abcd", "abcd123", "ax")))
     CHK("a" == lcPrefixC(c("a", "abcd123", "ax")))
     CHK("" == lcPrefixC(c("a", "abc", "xxx")))

