Learn R Programming

plu (version 0.3.0)

capitalize: Capitalization

Description

capitalize() returns a character vector x with the first alphabetic character replaced with a capital form (if one exists).

Usage

capitalize(x)

plu_capitalize(x)

is_capital(x, strict = FALSE)

is_capitalized(x, strict = FALSE)

Value

capitalize() returns a character vector of the same length as x.

is_capital() and is_capitalized() return a logical vector of the same length as x.

Arguments

x

A character vector.

strict

If strict is TRUE, is_capital() and is_capitalized() return FALSE instead of NA when characters are neither capital nor lowercase. Defualts to FALSE.

Details

is_capital() returns TRUE if all characters are capital, FALSE if all characters are lowercase, and NA if characters are mixed case or any characters are caseless (e.g. numbers, punctuation marks, characters from a unicase language like Arabic, Chinese or Hindi).

is_capitalized() returns TRUE if the first alphabetic character in a string is capital, FALSE if the first alphabetic character is lowercase, and NA if there are no alphabetic characters.

Examples

Run this code
capitalize(c("word", "a whole phrase"))
capitalize("preserving MIXED Case")
capitalize("... word")

is_capital(c("a", "A", "!"))
is_capital(c("aa", "AA", "!!"))
is_capital("Aa")

is_capitalized(c("a word", "A word", "a Word"))
is_capitalized("... A word")
is_capitalized("...")

Run the code above in your browser using DataLab