Numeric code for how to treat problems, consistent
with the argument warn in options:
Negative to ignore, 0 to save and print later, 1 to
print as they occur, 2 or greater to convert to errors.
unique
logical: TRUE to check that names(x) are
unique. Fix any duplicates with make.names.
avoid
a vector of regular expressions to avoid adding in the
output of make.names with a companion
replacement when found.
Thus, length(avoid) must be a nonnegative even
integer, with avoid[2*j-1] providing the
pattern for regexpr and
sub, and avoid[2*j] providing
the replacement. See the second example.
message0
Base to prepend to any message
...
optional arguments for make.names
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.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Ecfun)
Attaching package: 'Ecfun'
The following object is masked from 'package:base':
sign
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Ecfun/checkNames.Rd_%03d_medium.png", width=480, height=480)
> ### Name: checkNames
> ### Title: Check and return names
> ### Aliases: checkNames
> ### Keywords: manip
>
> ### ** Examples
>
> ##
> ## 1. standard operation with no names
> ##
> tst1 <- checkNames(1:2)
Warning message:
In checkNames(1:2) :
1:2: names = NULL; returning make.names(character(length(x))), TRUE)
>
> # check
> tst1. <- make.names(character(2), unique=TRUE)
> attr(tst1., 'message') <- paste(
+ "1:2: names = NULL; returning",
+ "make.names(character(length(x))), TRUE)")
> ## Don't show:
> stopifnot(
+ ## End(Don't show)
+ all.equal(tst1, tst1.)
+ ## Don't show:
+ )
> ## End(Don't show)
> ##
> ## 2. avoid=c('\.0$', '\.1$')
> ##
> tst2 <-checkNames(1:2,
+ avoid=c('\.0$', '.2',
+ '\.1$', '.3') )
Warning message:
In checkNames(1:2, avoid = c("\.0$", ".2", "\.1$", ".3")) :
1:2: names = NULL; returning make.names(character(length(x))), TRUE)
>
> # check
> tst2. <-c('X', 'X.3')
> attr(tst2., 'message') <- paste(
+ "1:2: names = NULL; returning",
+ "make.names(character(length(x))), TRUE)")
> ## Don't show:
> stopifnot(
+ ## End(Don't show)
+ all.equal(tst2, tst2.)
+ ## Don't show:
+ )
> ## End(Don't show)
>
>
>
>
>
> dev.off()
null device
1
>