getInit | R Documentation |
Convert or standardize a vector of containing people's names or their initials.
getInit(x, upper = TRUE, rm.spaces = TRUE, max.initials = 5)
x |
the character string or vector to be standardized |
upper |
logical. Should initials be capitalized? Default to TRUE. |
rm.spaces |
logical. Should spaces between initials be removed? Default to TRUE. |
max.initials |
numerical. Upper limit of number of letter for a single word to be considered as initials and not as a name. Default to 5. |
The function has some basic assumptions in order to get initials for the most type of cases.
For multiple names/abbreviations separated by a space and/or an abbreviation point, the function takes the first letter of each name/abbreviation as the initials.
For single names or one-string initials the output depends on the presence
of abbreviation points, if names are provided in all caps and in the number
of letters. If the number of capital letters exceeds the value in the
argument max.initials
, then it is taken as a name and not initials (see
Examples).
The output is relatively stable regarding different name formats and notation standards, but it doe not work for all of them (see Examples).
the character string with the initials of each name separated by points, without spaces. By default, initials are returned capitalized.
Renato A. F. de Lima
## Not run: # Full names and both full and abbreviated names getInit("Alwyn") getInit("Alwyn Howard Gentry") getInit("Alwyn H. Gentry") getInit("A. Gentry") getInit("A. H. Gentry") getInit("A.H.Gentry") # Abbreviations getInit("A") getInit("A H G") getInit("A. H. G.") # Capitalized and lower-case names getInit("ALWYN HOWARD GENTRY") getInit("AHG") getInit("a.h. gentry") getInit("alwyn") # assumes as name getInit("ALWYN") # assumes as name # Other formats getInit("Auguste Saint-Hilaire") getInit("John MacDonald") getInit("John McDonald") getInit("John O'Brien") # Some problematic (unresolved) examples getInit("AL") # assumes as initials (n. letters < default `max.initials`) getInit("AL", max.initials = 2) # assumes as name (by changing the default) getInit("Carl F. P. von Martius") #takes name preposition as name getInit("AH gentry") # assumes initials as first name getInit("Gentry, A.") # ignores comma getInit("G., Alwyn") # ignores comma getInit("Ah. Gentry") # discard the lower-case initial ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.