R/is.color.R

Defines functions is.color

Documented in is.color

#' @title is.color
#'
#' @description Function to define if each element of a string vector is an R-supported color string.
#'
#' @param x A string vector.
#'
#' @return A logical vector of the same length of \code{x}.
#'
#' @export is.color



is.color = function(x) {

  #-----------------------------#
  # Check if Rseb is up-to-date #
  Rseb::actualize(update = F, verbose = F)   #
  #-----------------------------#

  # Check x class
  if (class(x) != "character") {return(warning("The input must be a string vector."))}

  return(sapply(x,
                function(X) {
                  tryCatch(is.matrix(col2rgb(X)),
                           error = function(e) FALSE)},
                USE.NAMES = F))
}
sebastian-gregoricchio/Rseb documentation built on June 14, 2024, 12:22 p.m.