is_color: Check if elements in a character vector represent valid...

View source: R/input-check.R

is_colorR Documentation

Check if elements in a character vector represent valid colors.

Description

This function checks if each element in a character vector represents a valid color. It performs two checks:

  • It tests whether each element in the vector matches the pattern of a valid hexadecimal color code (e.g., "#RRGGBB").

  • It tests whether each element in the vector is one of the recognized color names in R.

Usage

is_color(vector)

Arguments

vector

A character vector containing color names or hexadecimal color codes.

Value

A logical vector of the same length as 'vector', where each element is 'TRUE' if the corresponding element in 'vector' represents a valid color, and 'FALSE' otherwise.

Examples

is_color(c("#FF0000", "blue", "invalid", "green"))


kueckelj/confuns documentation built on June 28, 2024, 9:19 a.m.