capFirst | R Documentation |
Capitalizes the first letter of first or all words in a string.
capFirst(x, which = c("all", "first"))
x |
A single string. |
which |
A single string that indicates whether all (the default) or only the first words should be capitalized. |
A single string with the first letter of the first or all words capitalized.
Derek H. Ogle, DerekOgle51@gmail.com
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.