proper: Capitalize the first letter (option: in each word)

View source: R/proper.R

properR Documentation

Capitalize the first letter (option: in each word)

Description

This is a riff on the Excel PROPER function which capitalizes the words in a given text string. Numbers and punctuation are not affected.

Usage

proper(x, just_first_word = TRUE)

Arguments

x

Character; the text that should be converted to proper case.

just_first_word

Logical; If TRUE (default) only the first letter of the first word of the text will be capitalized, else if FALSE then the first letter of each word will be capitalized.

Value

A chacter string

Examples

sample <- c("zachary taylor", "To be or not to be", "san diego, CA")
proper(sample)
proper(sample, just_first_word = FALSE)

another_sample <- c("this is a TITLE", "2-way street", "76BudGet")
proper(another_sample)
proper(another_sample, just_first_word = FALSE)


emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.