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")))

