

abbreviate {base}                            R Documentation

_A_b_b_r_e_v_i_a_t_e _S_t_r_i_n_g_s

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

     Abbreviate strings to at least `minlength' characters,
     such that they remain unique (if they were).

_U_s_a_g_e_:

     abbreviate(names.arg, minlength = 4, use.classes = TRUE,
                dot = FALSE)

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

names.arg: a vector of names to be abbreviated.

minlength: the minimum length of the abbreviations.

use.classes: logical (currently ignored by R).

     dot: logical; should a dot (`"."') be appended?

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

     The algorithm used is similar to that of S.  First
     spaces at the beginning of the word are stripped.  Then
     any other spaces are stripped.  Next lower case vowels
     are removed followed by lower case consonants.  Finally
     if the abbreviation is still longer than `minlength'
     upper case letters are stripped.

     Letters are always stripped from the end of the word
     first.  If an element of `names.arg' contains more than
     one word (words are separated by space) then at least
     one letter from each word will be retained.  If a sin-
     gle string is passed it is abbreviated in the same man-
     ner as a vector of strings.

     If `use.classes' is `FALSE' then the only distinction
     is to be between letters and space.  This has NOT been
     implemented.

_V_a_l_u_e_:

     A character vector containing abbreviations for the
     strings in its first argument.  Duplicates in the orig-
     inal `names.arg' will be given identical abbreviations.
     If any non-duplicated elements have the same `min-
     length' abbreviations then `minlength' is incremented
     by one and new abbreviations are found for those ele-
     ments only.  This process is repeated until all unique
     elements of `names.arg' have unique abbreviations.

     The character version of `names.arg' is attached to the
     returned value as a names argument.

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

     `substr'.

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

     x <- c("abcd", "efgh", "abce")
     abbreviate(x, 2)

     data(state)
     (st.abb <- abbreviate(state.name, 2))
     table(nchar(st.abb))# out of 50, 3 need 4 letters

