Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

FSAUtils

Capitalizes the first letter of first or all words in a string.


Description

Capitalizes the first letter of first or all words in a string.

Usage

capFirst(x, which = c("all", "first"))

Arguments

x

A single string.

which

A single string that indicates whether all (the default) or only the first words should be capitalized.

Value

A single string with the first letter of the first or all words capitalized.

Author(s)

Derek H. Ogle, derek@derekogle.com

Examples

## Capitalize first letter of all words (the default)
capFirst("Derek Ogle")
capFirst("derek ogle")
capFirst("derek")

## Capitalize first letter of only the first words
capFirst("Derek Ogle",which="first")
capFirst("derek ogle",which="first")
capFirst("derek",which="first")
## apply to all elements in a vector
vec <- c("Derek Ogle","derek ogle","Derek ogle","derek Ogle","DEREK OGLE")
capFirst(vec)
capFirst(vec,which="first")

## check class types
class(vec)
vec1 <- capFirst(vec)
class(vec1)
fvec <- factor(vec)
fvec1 <- capFirst(fvec)
class(fvec1)

FSA

Simple Fisheries Stock Assessment Methods

v0.8.32
GPL (>= 2)
Authors
Derek Ogle [aut, cre] (<https://orcid.org/0000-0002-0370-9299>), Powell Wheeler [aut], Alexis Dinno [aut] (Provided base functionality of dunnTest())
Initial release
2021-1-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.