nameAlnum {mefa4} | R Documentation |
Utility functions, mostly for character manipulation
Description
Utility functions, mostly for character manipulation.
Usage
pasteDate(..., sep = " ", collapse = NULL, sep.date = sep)
paste0date(..., collapse = NULL)
nameAlnum(x, capitalize=c("asis", "first", "none", "all", "mixed"),
collapse=" ")
normalizeNames(x, pattern = list(" "), replacement = list("_"),
alnum = FALSE, ...)
Arguments
x |
caharacter. |
... |
one or more R objects, to be converted to character vectors.
For |
sep |
a character string to separate the terms. |
collapse |
an optional character string to separate the results.
For |
sep.date |
a character string to separate the terms from the data itself. |
capitalize |
character, which letter of each words should be capitalized.
|
pattern |
a list of character vectors that are replaced.
Must match argument |
replacement |
a list of character vectors that are the replacements for |
alnum |
logical, if |
Value
Character vector with desired changes.
Author(s)
Peter Solymos <solymos@ualberta.ca>
See Also
Examples
paste0(pasteDate("file", "name", sep="-", sep.date="_"), ".csv")
paste0(paste0date("file", "name", sep.date="_"), ".csv")
data(abmibirds)
x <- data.frame(Name=levels(abmibirds[["Common.Name"]]),
NameAlnum=nameAlnum(levels(abmibirds[["Common.Name"]])),
stringsAsFactors = TRUE)
x[grep("'", x$Name),]
data.frame(out=sapply(c("asis", "first", "none", "all", "mixed"),
function(z) nameAlnum("Olive-sided Flycatcher", z)),
stringsAsFactors = TRUE)
z <- data.frame(Name=levels(abmibirds[["Common.Name"]]),
NameNormalized=normalizeNames(levels(abmibirds[["Common.Name"]]),
pattern=list("'", "-", " "), replacement=list("", "_", "_")),
stringsAsFactors = TRUE)
z[grepl("'", z$Name) & grepl("-", z$Name),]