Learn R Programming

humaniformat (version 0.6.0)

parse_names: Parse Human Names

Description

human names are complex things; sometimes people have honorifics, or not. Or a single middle name, or many. Or a compound surname, or not a compound surname but 'PhD' at the end of their name, and augh.

parse_names provides a simple function for taking consistently formatted human names and splitting them into salutation, first_name, middle_name, last_name and suffix. It is capable of dealing with compound surnames, multiple middle names, and similar variations, and is fully vectorised.

Usage

parse_names(names)

Arguments

names
a character vector of names to parse.

Value

a data.frame with the columns salutation, first_name, middle_name, last_name, suffix and full_name (which contains the original name). In the event that a name doesn't have a salutation, middle name, suffix, or so on, an NA will appear.

Examples

Run this code
# Parse a simple name
parse_names("Oliver Keyes")

# Parse a more complex name
parse_names("Hon. Oliver Timothy Keyes Esq.")

Run the code above in your browser using DataLab