Last data update: 2014.03.03

R: Utility functions, mostly for character manipulation
nameAlnumR 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=" ")
compare_sets(x, y)
find_max(x)
find_min(x)

Arguments

x, y

caharacter for nameAlnum, any type for compare_sets, matrix for find_max and find_min.

...

one or more R objects, to be converted to character vectors.

sep

a character string to separate the terms.

collapse

an optional character string to separate the results. For nameAlnum it is the separator between the words in the output.

sep.date

a character string to separate the terms from the data itself.

capitalize

character, which letter of each words should be capitalized. "mixed" capitalizes the first letter and case is unchanged for the rest. "first" capitalizes first letter and uses lower case for the rest. Other options are self explanatory.

Value

Character vector.

A matrix compare_sets.

A data frame for find_max and find_min.

Author(s)

Peter Solymos <solymos@ualberta.ca>

See Also

paste, paste0, strsplit, gsub

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"]])))
x[grep("'", x$Name),]

## numeric vector
compare_sets(1:10, 8:15)
## factor with 'zombie' labels
compare_sets(factor(1:10, levels=1:10), factor(8:15, levels=1:15))

(mat <- matrix(rnorm(10*5), 10, 5))
(m <- find_max(mat))
## column indices
as.integer(m$index)
find_min(mat)

Results