checkNames {Ecfun} | R Documentation |
Check and return names
Description
Check and return names
. If names are not
provided or are not unique, write a message and return
make.names
consistent with warn
and
unique
.
Usage
checkNames(x, warn=0, unique=TRUE,
avoid=character(0),
message0=head(deparse(substitute(x), 25), 2), ...)
Arguments
x |
an R object suitable for |
warn |
Numeric code for how to treat problems, consistent
with the argument |
unique |
logical: TRUE to check that |
avoid |
a vector of regular expressions to avoid adding in the
output of Thus, |
message0 |
Base to prepend to any message |
... |
optional arguments for |
Details
1. namex <- names(x)
2. Check per warn
and unique
3. Return an appropriate version of namex
Value
a character vector of the same length as x
. If any
problem is found, this character vector will have an
attribute message
describing the problem found.
Message checking considers unique
but ignores
warn
.
Author(s)
Spencer Graves
See Also
names
make.names
options
for warn
Examples
##
## 1. standard operation with no names
##
tst1 <- checkNames(1:2)
# check
tst1. <- make.names(character(2), unique=TRUE)
attr(tst1., 'message') <- paste(
"1:2: names = NULL; returning",
"make.names(character(length(x))), TRUE)")
all.equal(tst1, tst1.)
##
## 2. avoid=c('\\.0$', '\\.1$')
##
tst2 <-checkNames(1:2,
avoid=c('\\.0$', '.2',
'\\.1$', '.3') )
# check
tst2. <-c('X', 'X.3')
attr(tst2., 'message') <- paste(
"1:2: names = NULL; returning",
"make.names(character(length(x))), TRUE)")
all.equal(tst2, tst2.)