Learn R Programming

ds4psy (version 0.7.0)

capitalize: Capitalize initial characters in strings of text x.

Description

capitalize converts the case of each word's n initial characters (typically to upper) in a string of text x.

Usage

capitalize(x, n = 1, upper = TRUE, as_text = TRUE)

Arguments

x

A string of text (required).

n

Number of initial characters to convert. Default: n = 1.

upper

Convert to uppercase? Default: upper = TRUE.

as_text

Return word vector as text (i.e., one character string)? Default: as_text = TRUE.

Value

A character vector.

See Also

caseflip for converting the case of all letters.

Other text objects and functions: Umlaut, caseflip(), cclass, count_chars_words(), count_chars(), count_words(), l33t_rul35, map_text_chars(), map_text_coord(), map_text_regex(), metachar, read_ascii(), text_to_chars(), text_to_sentences(), text_to_words(), transl33t()

Examples

Run this code
# NOT RUN {
x <- c("Hello world! This is a 1st TEST sentence. The end.")
capitalize(x)
capitalize(x, n = 3)
capitalize(x, n = 2, upper = FALSE)
capitalize(x, as_text = FALSE)

# Note: A vector of character strings returns the same results: 
x <- c("Hello world!", "This is a 1st TEST sentence.", "The end.")
capitalize(x)
capitalize(x, n = 3)
capitalize(x, n = 2, upper = FALSE)
capitalize(x, as_text = FALSE)

# }

Run the code above in your browser using DataLab