Parses a full name string into components such as salutation, first name, middle name, last name, suffix, status, and inferred gender.
Usage
parse_name(
x,
prefixes = prx,
suffixes = sfx,
sanitize = FALSE,
split_initials = FALSE,
add_nicknames = FALSE,
split_run_together = FALSE
)Arguments
- x
A character string representing a person's name.
- prefixes
A character vector of salutations/prefixes to remove. Defaults to prx.
- suffixes
A character vector of suffixes to remove. Defaults to sfx.
- sanitize
Logical; if
TRUE, runsanitize_input()onxfirst. SetFALSE(the default) when the input has already been sanitized, asparse_names()does for the whole vector.- split_initials
Logical; if
TRUE, also split a stray initial fused onto a surname (Defect 3, e.g.CWOOLFOLK->C WOOLFOLK). Off by default because it is unreliable on a single record and can break legitimate names absent from the census; enable only where cross-year consensus can vet the output. Seedeglue_tokens().- add_nicknames
Logical; if
TRUE, append the nickname columns fromnickname_lookup(). Defaults toFALSE.- split_run_together
Logical; if
TRUE, first split a surname and given name written as one word (KramerKenneth,MURPHYSANDRA) withsplit_run_together(). The capital-letter rule needs the original case, so withsanitize = FALSEonly the all-capitals rule can apply. Defaults toFALSE.
Value
A one-row data.frame with columns salutation, first_name,
middle_name, last_name, suffix, status, gender, and
gender_confidence (plus the nickname columns if add_nicknames = TRUE).
Examples
parse_name("LIVINGSTON III MICHAEL JOHN")
#> salutation first_name middle_name last_name suffix status gender
#> 1 MICHAEL JOHN LIVINGSTON III M
#> gender_confidence
#> 1 99.8
parse_name("livingston III, Mr. MICHAEL JOHN9", sanitize = TRUE)
#> salutation first_name middle_name last_name suffix status gender
#> 1 MR MICHAEL JOHN LIVINGSTON III M
#> gender_confidence
#> 1 99.8