Skip to contents

[Stable]

extract_initials() extracts the initials of names in a character vector.

Usage

extract_initials(x, sep = ". ")

Arguments

x

A character vector with names.

sep

A character string to separate initials (Default: ". ").

Value

A character vector with the initials of names in x.

See also

Other string functions.: to_title_case_pt()

Examples

extract_initials(c("John Doe", "Jane Doe", "John Smith"))
#> [1] "J. D." "J. D." "J. S."
#> [1] "J. D." "J. D." "J. S." # Expected

extract_initials(c("John Doe", "Jane Doe", "John Smith"), sep = ".")
#> [1] "J.D." "J.D." "J.S."
#> [1] "J.D." "J.D." "J.S." # Expected