Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (30 sloc) 853 Bytes
#' Make syntactically valid names
#'
#' For `atomic` vectors, these functions will sanitize the values. Otherwise,
#' they will set [`names()`][base::names], [`rownames()`][base::rownames()],
#' and/or [`colnames()`][base::colnames] without modification of the values.
#'
#' @note [makeNames()] sanitizes names using underscores instead of dots, the
#' convention used by [`make.names()`][base::make.names].
#'
#' @export
#' @inheritParams base::make.names
#'
#' @seealso `make.names()`.
#'
#' @return `character`.
#'
#' @examples
#' data(mn, package = "acidtest")
#' names <- mn$character
#' makeNames(names)
makeNames <- function(names, unique = TRUE) {
assert(
is.atomic(names),
isFlag(unique)
)
names <- as.character(names)
names <- make.names(names, unique = unique)
names <- gsub("\\.", "_", names)
names
}
You can’t perform that action at this time.