| capitalize | R Documentation |
capitalize converts
the first n initial characters of
each element of a text string x (i.e., characters or words)
to upper- or lowercase.
capitalize(x, n = 1, upper = TRUE, as_text = FALSE)
x |
A string of text (required). |
n |
Number of initial characters to convert.
Default: |
upper |
Convert to uppercase?
Default: |
as_text |
Treat and return |
If as_text = TRUE, the input x is merged into
one string of text and the arguments are applied to each word.
A character vector.
caseflip for converting the case of all letters;
words_to_text and text_to_words for converting character vectors and texts.
Other text objects and functions:
Umlaut,
caseflip(),
cclass,
chars_to_text(),
collapse_chars(),
count_chars(),
count_chars_words(),
count_words(),
invert_rules(),
l33t_rul35,
map_text_chars(),
map_text_coord(),
map_text_regex(),
metachar,
read_ascii(),
text_to_chars(),
text_to_sentences(),
text_to_words(),
transl33t(),
words_to_text()
x <- c("Hello world!", "this is a TEST sentence.", "the end.")
capitalize(x)
capitalize(tolower(x))
# Options:
capitalize(x, n = 3) # leaves strings intact
capitalize(x, n = 3, as_text = TRUE) # treats strings as text
capitalize(x, n = 3, upper = FALSE) # first n in lowercase
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.