capitalise: Make Each Word Start with a Capital Letter

capitaliseR Documentation

Make Each Word Start with a Capital Letter

Description

Given a character string or vector of character strings containing words, change the start of each word to a capital letter.

Usage

capitalise(s, strict = FALSE)

Arguments

s

Character string or vector of character strings.

strict

Logical. If TRUE, all subsequent letters after the first letter in each word will be coerced to lower case.

Details

Each entry of s is split into separate words separated by the space character. Then the first letter of each word is coerced to a capital letter using toupper, and if strict=TRUE, subsequent letters are coerced to lower case using tolower. Then the words are replaced in their original positions in s.

Value

A character string or character vector of the same length as s.

Author(s)

Originally documented in base R. Code copied by \adrian.

See Also

toupper

Examples

  a <-  c("worKers", "of tHe", "worLd unIte")
  capitalise(a)
  capitalise(a, TRUE)

spatstat.utils documentation built on July 16, 2026, 5:08 p.m.