Make the first character of the elements of a character vector have upper case and the rest lower case.

capitalize(x)

Arguments

x

A character vector.

Details

The capitalize() function may be useful when applying lowercased dictionaries of stoplists, a sentiment dictionary etc. on a CWB corpus that maintains capitalization (tokens are not lowercased).

This function is inspired by a method Python offers for string objects.

Examples

capitalize(c("oil", "corpus", "data"))
#> [1] "Oil"    "Corpus" "Data"