capName: Capitalize Name

View source: R/capName.R

capNameR Documentation

Capitalize Name

Description

Capitalize the first letter of people's (last) names.

Usage

capName(x)

Arguments

x

the character string or vector to be capitalized.

Details

The function works for simple names and compound names that are separated by a space or by the character '-'. It also works for names that are entirely capitalized.

This function was conceived to edit people's last names. So, the function only works for up to two names and it works only partially for names containing initials.

For strings with more than two names, the function str_to_title() from package stringr can be used instead.

Value

the character string equal to x with the first letter capitalized.

Author(s)

Renato A. F. de Lima

Examples


## Not run: 
# Simple names
  capName("gentry")
  capName("HATSCHBACH")
  capName(c("gentry", "HATSCHBACH"))

# Names with generational suffixes
  capName("leitao filho")

# Compound last names
  capName("saint-hilaire")

# Other name formats
  capName("o'brien")
  capName("john o'brien")
  capName("MacDonald")
  capName("john MacDonald")

# Full (>2) names (does not work properly)
  capName("hermogenes leitao filho")
  capName("auguste saint-hilaire")
  capName("a.h. gentry")
  capName("AH gentry")
 
## End(Not run)


LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.