fix_name: Fix character variables

View source: R/fix_name.R

fix_nameR Documentation

Fix character variables

Description

Fix character variables by removing extraneous whitespace and possibly changing capitalization.

When using title case, words starting after an "-" are capitalized. A letter preceding an apostrophe (') is not capitalized. The words "and", "the" and "of" are not capitalized. Single letters alternated with dots (abbreviations) are capitalized.

Alternatively, you can get title case with tools::toTitleCase(fix_name(x, "lower"))

Usage

fix_name(x, case="", skip="", lowothers=TRUE)

Arguments

x

character

case

character. If this is not "", the capitalization of the words is changed. You can use "first", "lower", or "title"

skip

character. Additional words to skip when case="title" (see details)

lowothers

logical. Only relevant when case is "first" or "title". Should all other characters be made lowercase?

Value

character

Examples

d <- c("aruba", "BOM BINI", "saint-vincent and the grenadines",
       "the u.s. of america", "côte d'ivoire")
fix_name(d, "title")
fix_name(d, "title", skip="bini")

reagro/carobiner documentation built on Dec. 4, 2024, 3:21 p.m.